Esempio n. 1
0
        public static void TestInteropStrings()
        {
            {
                StructInfo <InteropString32> .size.ShouldBe(32 *sizeof(char));

                StructInfo <InteropString256> .size.ShouldBe(256 *sizeof(char));

                InteropString32 str       = "a short string";
                string          converted = str;
                str.ShouldEqual("a short string");
            }

            {
                string source = "aStringThatIsExactly31CharsLong";
                source.Length.ShouldBe(31);
                InteropString32 str       = source;
                string          converted = str;
                converted.ShouldEqual(source);
            }

            {
                string source = "a string that is much longer than thirty one characters long, but still less than two hundred and fifty six characters long.";
                (source.Length > 31).ShouldBeTrue();
                (source.Length < 256).ShouldBeTrue();

                InteropString32 str       = source;
                string          converted = str;
                converted.ShouldNotEqual(source);

                InteropString256 str256       = source;
                string           converted256 = str256;
                converted256.ShouldEqual(source);
            }
        }
Esempio n. 2
0
        public static InteropString32 FromJson(JsonValue value)
        {
            InteropString32 result = new InteropString32();

            if (value is JsonString str)
            {
                result.value = str;
            }
            else if (value is JsonArray arr)
            {
                for (int i = 0; i < MAX_LENGTH - 1; i++)
                {
                    result.fixedBuffer[i] = arr.Pull(i, '\0');
                }
            }
            return(result);
        }
Esempio n. 3
0
 public StringAndStuff(int x, string str, float y)
 {
     this.x = x; this.y = y; this.str = str;
 }