text:
using System;
using System.Globalization;
using NUnit.Framework;
using ZeroLog.Configuration;
using ZeroLog.Tests.Support;

namespace ZeroLog.Tests;

unsafe partial class LogMessageTests
{
    public abstract class ValueTypeTests<T> : LogMessageTests
        where T : unmanaged
    {
        protected void ShouldTruncateValue(Action action, bool formatted)
        {
            var requiredBufferSize = sizeof(ArgumentType) + sizeof(T) + (formatted ? sizeof(byte) : 0);

            // Ensure the message fits in the buffer as a sanity check
            _logMessage = LogMessage.CreateTestMessage(LogLevel.Info, requiredBufferSize, _stringCapacity);

            action.Invoke();

            _logMessage.IsTruncated.ShouldBeFalse();

            if (typeof(T) != typeof(byte) && typeof(T) != typeof(sbyte) && typeof(T) != typeof(char))
            {
                // Truncate because the output buffer is too small
                Span<char> smallBuffer = stackalloc char[2];
                _logMessage.WriteTo(smallBuffer, ZeroLogConfiguration.Default, LogMessage.FormatType.Formatted, null).ShouldEqual(smallBuffer.Length);
                smallBuffer.SequenceEqual(ZeroLogConfiguration.Default.TruncatedMessageSuffix.AsSpan(0, smallBuffer.Length)).ShouldBeTrue();
            }

            // Edge case: empty output buffer
            _logMessage.WriteTo(Span<char>.Empty, ZeroLogConfiguration.Default, LogMessage.FormatType.Formatted, null).ShouldEqual(0);

            // Truncate because the log message buffer is too small
            _logMessage = LogMessage.CreateTestMessage(LogLevel.Info, requiredBufferSize - 1, _stringCapacity);

            action.Invoke();

            _logMessage.IsTruncated.ShouldBeTrue();
            _logMessage.ToString().ShouldEqual(ZeroLogConfiguration.Default.TruncatedMessageSuffix);

            // Edge case: empty log message buffer
            _logMessage = LogMessage.CreateTestMessage(LogLevel.Info, 0, _stringCapacity);

            action.Invoke();

            _logMessage.IsTruncated.ShouldBeTrue();
        }

        // The following methods help reduce the number of casts in the code,
        // which ensures the correct overload is called after the code is copied from one type to another.

        protected static T? AsNullable(T value)
            => value;

        protected static T? GetNullValue()
            => null;
    }

    [TestFixture]
    public class BoolTests : ValueTypeTests<bool>
    {
        private const bool _value = true;

        [Test]
        public void should_append_value([Values] bool value)
            => _logMessage.Append(value).ToString().ShouldEqual(value.ToString());

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString());

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_value_through_interpolation([Values] bool value)
            => _logMessage.Append($"{value}").ToString().ShouldEqual(value.ToString());

        [Test]
        public void should_append_nullable_value_through_interpolation([Values] bool value)
            => _logMessage.Append($"{AsNullable(value)}").ToString().ShouldEqual(value.ToString());

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));
    }

    [TestFixture]
    public class ByteTests : ValueTypeTests<byte>
    {
        private const byte _value = 42;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        public void should_not_allocate_formatted()
            => ShouldNotAllocate(() => _logMessage.Append(_value, "X"));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class SByteTests : ValueTypeTests<sbyte>
    {
        private const sbyte _value = -42;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        public void should_not_allocate_formatted()
            => ShouldNotAllocate(() => _logMessage.Append(_value, "X"));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class CharTests : ValueTypeTests<char>
    {
        private const char _value = 'x';

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));
    }

    [TestFixture]
    public class ShortTests : ValueTypeTests<short>
    {
        private const short _value = short.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("X")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class UShortTests : ValueTypeTests<ushort>
    {
        private const ushort _value = ushort.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("X")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class Int32Tests : ValueTypeTests<int>
    {
        private const int _value = int.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("X")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class UInt32Tests : ValueTypeTests<uint>
    {
        private const uint _value = uint.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("X")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class Int64Tests : ValueTypeTests<long>
    {
        private const long _value = long.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("X")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class UInt64Tests : ValueTypeTests<ulong>
    {
        private const ulong _value = ulong.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("X")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class IntPtrTests : ValueTypeTests<nint>
    {
        private static readonly nint _value = nint.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("X")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class UIntPtrTests : ValueTypeTests<nuint>
    {
        private static readonly nuint _value = nuint.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "X").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "X").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):X}").ToString().ShouldEqual(_value.ToString("X", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():X}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "X"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("X")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:X}"));
    }

    [TestFixture]
    public class SingleTests : ValueTypeTests<float>
    {
        private const float _value = float.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "F2").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "F2").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "F2").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:F2}").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):F2}").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():F2}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "F2"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(42.5f));

        [Test]
        [TestCase("P")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:F2}"));
    }

    [TestFixture]
    public class DoubleTests : ValueTypeTests<double>
    {
        private const double _value = double.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "F2").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "F2").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "F2").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:F2}").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):F2}").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():F2}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "F2"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("P")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:F2}"));
    }

    [TestFixture]
    public class DecimalTests : ValueTypeTests<decimal>
    {
        private const decimal _value = decimal.MaxValue;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value()
            => _logMessage.Append(_value, "F2").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "F2").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(AsNullable(_value), "F2").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:F2}").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):F2}").ToString().ShouldEqual(_value.ToString("F2", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():F2}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "F2"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("P")]
        [TestCase("F2")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:F2}"));
    }

    [TestFixture]
    public class GuidTests : ValueTypeTests<Guid>
    {
        private static readonly Guid _value = Guid.NewGuid();

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        [TestCase("N")]
        [TestCase("D")]
        [TestCase("B")]
        public void should_append_formatted_value(string format)
            => _logMessage.Append(_value, format).ToString().ShouldEqual(_value.ToString(format, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "D").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(_value, "D").ToString().ShouldEqual(_value.ToString("D", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:D}").ToString().ShouldEqual(_value.ToString("D", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):D}").ToString().ShouldEqual(_value.ToString("D", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():D}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "D"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("N")]
        [TestCase("D")]
        [TestCase("B")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:B}"));
    }

    [TestFixture]
    public class DateTimeTests : ValueTypeTests<DateTime>
    {
        private static readonly DateTime _value = DateTime.UtcNow;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        [TestCase("d")]
        [TestCase("D")]
        [TestCase("yyyy-MM-dd")]
        public void should_append_formatted_value(string format)
            => _logMessage.Append(_value, format).ToString().ShouldEqual(_value.ToString(format, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "D").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(_value, "D").ToString().ShouldEqual(_value.ToString("D", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:yyyy}").ToString().ShouldEqual(_value.ToString("yyyy", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):yyyy}").ToString().ShouldEqual(_value.ToString("yyyy", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():yyyy}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "D"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("d")]
        [TestCase("D")]
        [TestCase("yyyy-MM-dd")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:yyyy-MM-dd}"));
    }

    [TestFixture]
    public class TimeSpanTests : ValueTypeTests<TimeSpan>
    {
        private static readonly TimeSpan _value = DateTime.UtcNow.TimeOfDay;

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        [TestCase("c")]
        [TestCase("G")]
        public void should_append_formatted_value(string format)
            => _logMessage.Append(_value, format).ToString().ShouldEqual(_value.ToString(format, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "G").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(_value, "c").ToString().ShouldEqual(_value.ToString("c", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:c}").ToString().ShouldEqual(_value.ToString("c", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):c}").ToString().ShouldEqual(_value.ToString("c", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():c}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "c"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("c")]
        [TestCase("G")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:c}"));
    }

    [TestFixture]
    public class DateOnlyTests : ValueTypeTests<DateOnly>
    {
        private static readonly DateOnly _value = DateOnly.FromDateTime(DateTime.UtcNow);

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        [TestCase("d")]
        [TestCase("D")]
        [TestCase("yyyy-MM-dd")]
        public void should_append_formatted_value(string format)
            => _logMessage.Append(_value, format).ToString().ShouldEqual(_value.ToString(format, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "D").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(_value, "D").ToString().ShouldEqual(_value.ToString("D", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:yyyy}").ToString().ShouldEqual(_value.ToString("yyyy", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):yyyy}").ToString().ShouldEqual(_value.ToString("yyyy", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():yyyy}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "D"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("d")]
        [TestCase("D")]
        [TestCase("yyyy-MM-dd")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:yyyy-MM-dd}"));
    }

    [TestFixture]
    public class TimeOnlyTests : ValueTypeTests<TimeOnly>
    {
        private static readonly TimeOnly _value = TimeOnly.FromDateTime(DateTime.UtcNow);

        [Test]
        public void should_append_value()
            => _logMessage.Append(_value).ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value()
            => _logMessage.Append(AsNullable(_value)).ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null()
            => _logMessage.Append(GetNullValue()).ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        [TestCase("t")]
        [TestCase("T")]
        public void should_append_formatted_value(string format)
            => _logMessage.Append(_value, format).ToString().ShouldEqual(_value.ToString(format, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null()
            => _logMessage.Append(GetNullValue(), "T").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_nullable_formatted_value()
            => _logMessage.Append(_value, "t").ToString().ShouldEqual(_value.ToString("t", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_value_through_interpolation()
            => _logMessage.Append($"{_value}").ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value)}").ToString().ShouldEqual(_value.ToString(null, CultureInfo.InvariantCulture));

        [Test]
        public void should_append_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue()}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_append_formatted_value_through_interpolation()
            => _logMessage.Append($"{_value:t}").ToString().ShouldEqual(_value.ToString("t", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_nullable_formatted_value_through_interpolation()
            => _logMessage.Append($"{AsNullable(_value):t}").ToString().ShouldEqual(_value.ToString("t", CultureInfo.InvariantCulture));

        [Test]
        public void should_append_formatted_null_value_through_interpolation()
            => _logMessage.Append($"{GetNullValue():c}").ToString().ShouldEqual(ZeroLogConfiguration.Default.NullDisplayString);

        [Test]
        public void should_truncate_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value), false);

        [Test]
        public void should_truncate_formatted_value()
            => ShouldTruncateValue(() => _logMessage.Append(_value, "t"), true);

        [Test]
        public void should_not_allocate()
            => ShouldNotAllocate(() => _logMessage.Append(_value));

        [Test]
        [TestCase("t")]
        [TestCase("T")]
        public void should_not_allocate_formatted(string format)
            => ShouldNotAllocate(() => _logMessage.Append(_value, format));

        [Test]
        public void should_not_allocate_interpolation()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value}"));

        [Test]
        public void should_not_allocate_interpolation_formatted()
            => ShouldNotAllocate(() => _logMessage.Append($"{_value:t}"));
    }
}


text:
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<link rel="stylesheet" type="text/css" href="../../../scineplex.css">
<title></title>
<link rel="stylesheet" href="../../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />

NAME

VERSION

DESCRIPTION

SYNOPSIS

METHODS

Class Methods

NAME

TAP::Formatter::Base - Base class for harness output delegates

VERSION

Version 3.25

DESCRIPTION

This provides console orientated output formatting for TAP::Harness.

SYNOPSIS

 use TAP::Formatter::Console;
 my $harness = TAP::Formatter::Console->new( \%args );

METHODS

Class Methods

new

 my %args = (
    verbose => 1,
 )
 my $harness = TAP::Formatter::Console->new( \%args );

The constructor returns a new TAP::Formatter::Console object. If a TAP::Harness is created with no formatter a TAP::Formatter::Console is automatically created. If any of the following options were given to TAP::Harness->new they well be passed to this constructor which accepts an optional hashref whose allowed keys are:

verbosity

Set the verbosity level.

verbose

Printing individual test results to STDOUT.

timer

Append run time for each test to output. Uses Time::HiRes if available.

failures

Show test failures (this is a no-op if verbose is selected).

comments

Show test comments (this is a no-op if verbose is selected).

quiet

Suppressing some test output (mostly failures while tests are running).

really_quiet

Suppressing everything but the tests summary.

silent

Suppressing all output.

errors

If parse errors are found in the TAP output, a note of this will be made in the summary report. To see all of the parse errors, set this argument to true:

  errors => 1

directives

If set to a true value, only test results with directives will be displayed. This overrides other settings such as verbose, failures, or comments.

stdout

A filehandle for catching standard output.

color

If defined specifies whether color output is desired. If color is not defined it will default to color output if color support is available on the current platform and output is not being redirected.

jobs

The number of concurrent jobs this formatter will handle.

show_count

Boolean value. If false, disables the X/Y test count which shows up while tests are running.

Any keys for which the value is undef will be ignored.

prepare

Called by Test::Harness before any test output is generated.

This is an advisory and may not be called in the case where tests are being supplied to Test::Harness by an iterator.

open_test

Called to create a new test session. A test session looks like this:

    my $session = $formatter->open_test( $test, $parser );
    while ( defined( my $result = $parser->next ) ) {
        $session->result($result);
        exit 1 if $result->is_bailout;
    }
    $session->close_test;

summary

  $harness->summary( $aggregate );

summary prints the summary report after all tests are run. The first argument is an aggregate to summarise. An optional second argument may be set to a true value to indicate that the summary is being output as a result of an interrupted test run.

redpajama_set_name: RedPajamaGithub


text:
require 'data_mapper'
# full path!
DataMapper.setup(:default,
                 ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/database.db" )

class PL0Program
  include DataMapper::Resource

  property :name, String, :key => true
  property :source, String, :length => 1..1024
end

DataMapper.finalize
DataMapper.auto_upgrade!


text:
import org.scalatest._

class StubFunSpec extends FunSpec {
  describe("My class") {
    it("""should do something interesting""") (pending)
    it("""shouldn't throw exceptions""") (pending)
  }
}

class StubSpec extends FlatSpec {

  "My Class" should "do something interesting" in {
    is (pending)
  }
}


text:
import json

import locust

TOKEN_PATH = 'http://172.29.236.100:5000/v3/auth/tokens'

class Task(locust.TaskSet):
    @locust.task
    def authenticate(self):
        # authenticate for a token and validate it
        with open('auth.json', 'r') as f:
            body = json.loads(f.read())
        headers = {'Content-Type': 'application/json'}
        response = self.client.post(TOKEN_PATH, json=body, headers=headers)
        token = response.headers.get('X-Subject-Token')
        headers = {
            'X-Subject-Token': token,
            'X-Auth-Token': token
        }
        self.client.get(TOKEN_PATH, headers=headers)

class MyLocust(locust.HttpLocust):
    task_set = Task


text:
$( document ).ready(function() {
    if (typeof jQuery.ui !== 'undefined'){
        $( ".resizeable" ).resizable();
    }

    $('.mdl-layout').on('mdl-componentupgraded', function(e) {
        if ($(e.target).hasClass('mdl-layout')) {
            adjustHeight();
        }
    });

    setTimeout(function(){
        adjustHeight();
    }, 100);

    //Resize content if inside iframe, when switching tab
    $('.mdl-tabs__tab').on('click',function(){
        setTimeout(function(){
            adjustHeight();
        }, 50);
     });
})

function generateAjaxPostData(){
    var data = {};
    var sessions = getParameterByName("ls-sessions");
    if(sessions !== undefined){
        data["ls-sessions"] = sessions;
    }

    return data;
}
function adjustHeight(){
    if(parent.AdjustIframeHeight !== undefined){
        var newHeight = document.getElementById("gw2i-container").scrollHeight;
        console.log(newHeight);
//        if(newHeight <= 0) {
//            newHeight = $(".mdl-layout__tab-panel.is-active").outerHeight() + 120;
//            console.log(newHeight);
//        }
        parent.AdjustIframeHeight(newHeight + 10);
    }
}
function getParameterByName(name, url) {
    if (!url)
        url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
    if (!results)
        return null;
    if (!results[2])
        return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

function setCookie(cname, cvalue, exseconds) {
    var d = new Date();
    d.setTime(d.getTime() + (exseconds*1000));
    var expires = "expires="+ d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}

function decodeEntities(encodedString) {
    var textArea = document.createElement('textarea');
    textArea.innerHTML = encodedString;
    return textArea.value;
}

function mergeObjects(obj1,obj2){
    return jQuery.extend(true, obj1, obj2);
}

function scrollToBottom(container){
    $(container).scrollTop($(container)[0].scrollHeight);
}

function addNotitification(msg, type){
    $("#gw2i-notification-container").append('
'+msg+'
');
}

function getAccessLabelsFromAccessIds(accessIds) {
    var accessList = [];
    var index = accessIds.indexOf("0");
    if(index >= 0){
        accessList.push("GuildWars2");
    }
    index = accessIds.indexOf("1");
    if(index >= 0){
        accessList.push("Heart of Thorns");
    }
    index = accessIds.indexOf("2");
    if(index >= 0){
        accessList.push("Play For Free");
    }
    index = accessIds.indexOf("3");
    if(index >= 0){
        accessList.push("None");
    }
    index = accessIds.indexOf("4");
    if(index >= 0){
        accessList.push("Path Of Fire");
    }
    index = accessIds.indexOf("-1");
    if(index >= 0){
        accessList.push("Temporary");
    }
    return accessList;
}

function getWorldNameFromId(worldId) {
    return world_names[worldId];
}

function nextPage($inputCounter){
    console.log($inputCounter);
    test = $inputCounter;
    var page = parseInt($inputCounter.val());
    page++;
    $inputCounter.val(page);
}
function prevPage($inputCounter){
    var page = parseInt($inputCounter.val());
    if(page > 1){
        page--;
        $inputCounter.val(page);
    }
}

//Pre-saved list of server names to avoid contacting the GW2 api each time to fetch
//the server names
var world_names = {
    1001: "Anvil Rock",
    1002: "Borlis Pass",
    1003: "Yak's Bend",
    1004: "Henge of Denravi",
    1005: "Maguuma",
    1006: "Sorrow's Furnace",
    1007: "Gate of Madness",
    1008: "Jade Quarry",
    1009: "Fort Aspenwood",
    1010: "Ehmry Bay",
    1011: "Stormbluff Isle",
    1012: "Darkhaven",
    1013: "Sanctum of Rall",
    1014: "Crystal Desert",
    1015: "Isle of Janthir",
    1016: "Sea of Sorrows",
    1017: "Tarnished Coast",
    1018: "Northern Shiverpeaks",
    1019: "Blackgate",
    1020: "Ferguson's Crossing",
    1021: "Dragonbrand",
    1022: "Kaineng",
    1023: "Devona's Rest",
    1024: "Eredon Terrace",
    2001: "Fissure of Woe",
    2002: "Desolation",
    2003: "Gandara",
    2004: "Blacktide",
    2005: "Ring of Fire",
    2006: "Underworld",
    2007: "Far Shiverpeaks",
    2008: "Whiteside Ridge",
    2009: "Ruins of Surmia",
    2010: "Seafarer's Rest",
    2011: "Vabbi",
    2012: "Piken Square",
    2013: "Aurora Glade",
    2014: "Gunnar's Hold",
    2101: "Jade Sea [FR]",
    2102: "Fort Ranik [FR]",
    2103: "Augury Rock [FR]",
    2104: "Vizunah Square [FR]",
    2105: "Arborstone [FR]",
    2201: "Kodash [DE]",
    2202: "Riverside [DE]",
    2203: "Elona Reach [DE]",
    2204: "Abaddon's Mouth [DE]",
    2205: "Drakkar Lake [DE]",
    2206: "Miller's Sound [DE]",
    2207: "Dzagonur [DE]",
    2301: "Baruch Bay [SP]"
};


text:
namespace chromecast {
namespace media {
namespace mixer_service {

// Mixer service connection for controlling general mixer properties, such as
// device volume and postprocessor configuration. Not thread-safe; all usage of
// a given instance must be on the same sequence. Must be created on an IO
// thread.
class ControlConnection : public MixerConnection, public MixerSocket::Delegate {
 public:
  using ConnectedCallback = base::RepeatingClosure;

  // Callback to receive mixer stream count changes.
  using StreamCountCallback =
      base::RepeatingCallback<void(int primary_streams, int sfx_streams)>;

  // Callback that handles ListPostProcessors response.
  using ListPostprocessorsCallback =
      base::OnceCallback<void(const std::vector<std::string>&)>;

  ControlConnection();

  ControlConnection(const ControlConnection&) = delete;
  ControlConnection& operator=(const ControlConnection&) = delete;

  ~ControlConnection() override;

  // Connects to the mixer. If the mixer connection is lost, this will
  // automatically reconnect. If |callback| is nonempty, it will be called each
  // time a connection is (re)established with the mixer. This can be used to
  // re-send postprocessor messages, since they are not persisted across
  // disconnects.
  void Connect(ConnectedCallback callback = ConnectedCallback());

  // Sets volume multiplier for all streams of a given content type.
  void SetVolume(AudioContentType type, float volume_multiplier);

  // Sets mute state all streams of a given content type.
  void SetMuted(AudioContentType type, bool muted);

  // Sets the maximum effective volume multiplier for a given content type.
  void SetVolumeLimit(AudioContentType type, float max_volume_multiplier);

  // Returns a set of registered builtin post-processors.
  void ListPostprocessors(ListPostprocessorsCallback callback);

  // Sends arbitrary config data to a specific postprocessor. Config is saved
  // for each unique |name| and will be resent if the mixer disconnects and then
  // reconnects. If the |postprocessor_name| contains a '?', that character and
  // the remainder of the name string will not be sent to the mixer; this is
  // useful for configuring multiple subprocessors (eg for the dynamic range
  // processor).
  void ConfigurePostprocessor(std::string postprocessor_name,
                              std::string config);

  // Sends a message a specific postprocessor. Messages are not saved and will
  // not be resent if the mixer disconnects and then reconnects.
  void SendPostprocessorMessage(std::string postprocessor_name,
                                std::string message);

  // Instructs the mixer to reload postprocessors based on the config file.
  void ReloadPostprocessors();

  // Sets a callback to receive mixer stream count changes. |callback| may be an
  // empty callback to remove it.
  void SetStreamCountCallback(StreamCountCallback callback);

  // Sets the desired number of output channels used by the mixer. This will
  // cause an audio interruption on any currently active streams. The actual
  // output channel count is determined by the output implementation and may not
  // match |num_channels|.
  void SetNumOutputChannels(int num_channels);

 private:
  bool SendPostprocessorMessageInternal(std::string postprocessor_name,
                                        std::string message);
  void OnSendFailed();

  // MixerConnection implementation:
  void OnConnected(std::unique_ptr<MixerSocket> socket) override;
  void OnConnectionError() override;

  // MixerSocket::Delegate implementation:
  bool HandleMetadata(const Generic& message) override;

  std::unique_ptr<MixerSocket> socket_;

  ConnectedCallback connect_callback_;

  base::flat_map<AudioContentType, float> volume_;
  base::flat_map<AudioContentType, bool> muted_;
  base::flat_map<AudioContentType, float> volume_limit_;

  base::flat_map<std::string, std::string> postprocessor_config_;

  StreamCountCallback stream_count_callback_;
  // Uses std::list to trigger callbacks in FIFO order.
  std::list<ListPostprocessorsCallback> list_postprocessors_callbacks_;
  int num_output_channels_ = 0;
};

}  // namespace mixer_service
}  // namespace media
}  // namespace chromecast

#endif  // CHROMECAST_MEDIA_AUDIO_MIXER_SERVICE_CONTROL_CONNECTION_H_


text:
package function

import (
	cesql "github.com/cloudevents/sdk-go/sql/v2"
	cloudevents "github.com/cloudevents/sdk-go/v2"
)

var AbsFunction function = function{
	name:         "ABS",
	fixedArgs:    []cesql.Type{cesql.IntegerType},
	variadicArgs: nil,
	fn: func(event cloudevents.Event, i []interface{}) (interface{}, error) {
		x := i[0].(int32)
		if x < 0 {
			return -x, nil
		}
		return x, nil
	},
}


text:
const body = require('koa-body');

module.exports = function (options) {

    return async function (ctx, next) {
        await body(options)(ctx, function () {
            return new Promise((resolve, reject) => {
                if (!ctx.request.body.files) {
                    ctx.post = ctx.request.body;
                } else {
                    ctx.post = ctx.request.body.fields;
                    ctx.file = ctx.request.body.files;
                }
                resolve(true);
            });
        });

        await next();
    }
};


text:
require 'elasticsearch/model/extensions/all'

RSpec.shared_examples 'a document updates outer documents on changed' do
  describe 'an article' do
    def article
      ::Article.search('Comment1').records.first
    end

    context 'with a comment added' do
      before(:each) do
        article.comments.create(body: 'Comment2')

        Article.__elasticsearch__.refresh_index!
      end

      specify {
        expect(Article.search('Comment1').records.first).not_to be_nil
        expect(Article.search('Comment2').records.first).not_to be_nil
      }
    end

    context 'with a comment updated' do
      before(:each) do
        article.comments.first.update_attributes body: 'Comment3'

        Article.__elasticsearch__.refresh_index!
      end

      specify {
        expect(Article.search('Comment1').records.first).to be_nil
      }

      specify {
        expect(Article.search('Comment3').records.first).not_to be_nil
      }
    end

    context 'when a comment destroyed' do
      before(:each) do
        article.comments.first.destroy

        Article.__elasticsearch__.refresh_index!
      end

      specify 'the article is updated' do
        expect(Article.search('Comment1').records).to be_empty
      end

      specify 'the comment becomes unsearchable' do
        expect(Comment.search('Comment1').records).to be_empty
      end
    end
  end
end

RSpec.describe Elasticsearch::Model::Extensions::OuterDocumentUpdating do
  context 'having articles with comments' do
    before(:each) do
      load 'setup/articles_with_comments.rb'
    end

    after :each do
      ActiveRecord::Schema.define(:version => 2) do
        drop_table :comments
        drop_table :articles
      end
    end

    it_behaves_like 'a document updates outer documents on changed'
  end

  context 'having articles with comments and delayed jobs' do
    before(:each) do
      load 'setup/articles_with_comments_and_delayed_jobs.rb'
    end

    after :each do
      ActiveRecord::Schema.define(:version => 2) do
        drop_table :comments
        drop_table :articles
        drop_table :delayed_jobs
      end
    end

    it_behaves_like 'a document updates outer documents on changed'
  end
end


text:
set -eo pipefail

# Constants
readonly GITHUB_REPOSITORY_NAME="grpc-node"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/grpc/${TEST_DRIVER_BRANCH:-master}/tools/internal_ci/linux/grpc_xds_k8s_install_test_driver.sh"
## xDS test client Docker images
readonly SERVER_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/java-server:v1.46.x"
readonly CLIENT_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/node-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="packages/grpc-js-xds/interop/Dockerfile"
readonly LANGUAGE_NAME="Node"

#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
#   BUILD_APP_PATH
#   CLIENT_IMAGE_NAME: Test client Docker image name
#   GIT_COMMIT: SHA-1 of git commit being built
#   TESTING_VERSION: version branch under test, f.e. v1.42.x, master
# Arguments:
#   None
# Outputs:
#   Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
  echo "Building ${LANGUAGE_NAME} xDS interop test app Docker images"

  pushd "${SRC_DIR}"
  docker build \
    -f "${BUILD_APP_PATH}" \
    -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
    .

  gcloud -q auth configure-docker
  docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
  if is_version_branch "${TESTING_VERSION}"; then
    tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
  fi
  popd
}

#######################################
# Builds test app and its docker images unless they already exist
# Globals:
#   CLIENT_IMAGE_NAME: Test client Docker image name
#   GIT_COMMIT: SHA-1 of git commit being built
#   FORCE_IMAGE_BUILD
# Arguments:
#   None
# Outputs:
#   Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
  # Check if images already exist
  client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
  printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
  echo "${client_tags:-Client image not found}"

  # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
  if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${client_tags}" ]]; then
    build_test_app_docker_images
  else
    echo "Skipping ${LANGUAGE_NAME} test app build"
  fi
}

#######################################
# Executes the test case
# Globals:
#   TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
#   KUBE_CONTEXT: The name of kubectl context with GKE cluster access
#   SECONDARY_KUBE_CONTEXT: The name of kubectl context with secondary GKE cluster access, if any
#   TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
#   CLIENT_IMAGE_NAME: Test client Docker image name
#   GIT_COMMIT: SHA-1 of git commit being built
# Arguments:
#   Test case name
# Outputs:
#   Writes the output of test execution to stdout, stderr
#   Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
  # Test driver usage:
  # https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage
  local test_name="${1:?Usage: run_test test_name}"
  local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
  mkdir -pv "${out_dir}"
  # testing_version is used by the framework to determine the supported PSM
  # features. It's captured from Kokoro job name of the Node repo, which takes
  # the form:
  #   grpc/node/<branch name>/<job name>
  python3 -m "tests.${test_name}" \
    --flagfile="${TEST_DRIVER_FLAGFILE}" \
    --kube_context="${KUBE_CONTEXT}" \
    --secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \
    --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
    --server_image="${SERVER_IMAGE_NAME}" \
    --testing_version="${TESTING_VERSION}" \
    --force_cleanup \
    --collect_app_logs \
    --log_dir="${out_dir}" \
    --xml_output_file="${out_dir}/sponge_log.xml" \
    |& tee "${out_dir}/sponge_log.log"
}

#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
#   KOKORO_ARTIFACTS_DIR
#   GITHUB_REPOSITORY_NAME
#   SRC_DIR: Populated with absolute path to the source repo
#   TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
#                         the test driver
#   TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
#   TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
#   TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
#   GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
#   GIT_COMMIT: Populated with the SHA-1 of git commit being built
#   GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
#   KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
#   SECONDARY_KUBE_CONTEXT: Populated with name of kubectl context with secondary GKE cluster access, if any
# Arguments:
#   None
# Outputs:
#   Writes the output of test execution to stdout, stderr
#######################################
main() {
  local script_dir
  script_dir="$(dirname "$0")"

  cd "${script_dir}"

  git submodule update --init --recursive

  # Source the test driver from the master branch.
  echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
  source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"

  activate_gke_cluster GKE_CLUSTER_PSM_LB
  activate_secondary_gke_cluster GKE_CLUSTER_PSM_LB

  set -x
  if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
    kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
  else
    local_setup_test_driver "${script_dir}"
  fi
  build_docker_images_if_needed

  # Run tests
  cd "${TEST_DRIVER_FULL_DIR}"
  local failed_tests=0
  test_suites=("baseline_test" "api_listener_test" "change_backend_service_test" "failover_test" "remove_neg_test" "round_robin_test" "outlier_detection_test")
  for test in "${test_suites[@]}"; do
    run_test $test || (( failed_tests++ ))
  done
  echo "Failed test suites: ${failed_tests}"
  if (( failed_tests > 0 )); then
    exit 1
  fi
}

main "$@"


text:
package org.olat.commons.calendar.ui;

import java.util.Date;

import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.DateChooser;
import org.olat.core.gui.components.form.flexible.elements.FormLink;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormEvent;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.translator.Translator;

public class GotoDateCalendarsForm extends FormBasicController {
	private DateChooser gotoDate;
	private FormLink gotoDateLink;

	public GotoDateCalendarsForm(UserRequest ureq, WindowControl wControl, Translator translator) {
		super(ureq, wControl);
		setTranslator(translator);
		initForm(ureq);
	}

	@Override
	protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
		FormLayoutContainer horizontalL = FormLayoutContainer.createHorizontalFormLayout("horiz", getTranslator());
		formLayout.add(horizontalL);
		gotoDate = uifactory.addDateChooser("goto", null, null, horizontalL);//null because no label is desired.
		gotoDate.setMandatory(false);
		gotoDate.setDate(new Date());
		gotoDateLink =  uifactory.addFormLink("cal.search.gotodate.button", horizontalL,Link.BUTTON);
	}

	@Override
	protected void doDispose() {
		//empty
	}

	@Override
	protected boolean validateFormLogic(UserRequest ureq) {
		boolean isInputValid = true;
		if (gotoDate.hasError() || (getGotoDate() == null) ) {
			gotoDate.setErrorKey("error.goto.date", new String[0]);
			return false;
		}
		return isInputValid;
	}

	@Override
	protected void formInnerEvent(UserRequest ureq, org.olat.core.gui.components.form.flexible.FormItem source, FormEvent event) {
		if(source == gotoDateLink){
			this.flc.getRootForm().submit(ureq);
		}
	}

	@Override
	protected void formOK(UserRequest ureq) {
		fireEvent(ureq, Event.DONE_EVENT);
	}

	@Override
	protected void formResetted(UserRequest ureq) {
		fireEvent(ureq, Event.CANCELLED_EVENT);
	}

	public Date getGotoDate() {
		return gotoDate.getDate();
	}

}