public void ListValue() { SKONObject listObj = TestStringList; Assert.AreEqual(SKONValueType.ARRAY, listObj.Type); IsNotEmpty(listObj); IsComplexType(listObj); IsNotSimpleType(listObj); Assert.AreNotEqual(-1, listObj.Length); Assert.AreEqual(6, listObj.Values.Count); Assert.AreEqual(listObj.Values.Count, listObj.Length); SKONObject emptyObj = listObj[0]; IsEmpty(emptyObj); IsNotComplexType(emptyObj); IsNotSimpleType(emptyObj); SKONObject stringObj = listObj[1]; IsNotEmpty(stringObj); IsNotComplexType(stringObj); Assert.AreEqual(TestString, stringObj.String); SKONObject intObj = listObj[2]; IsNotEmpty(intObj); IsNotComplexType(intObj); Assert.AreEqual(TestInt, intObj.Int); SKONObject doubleObj = listObj[3]; IsNotEmpty(doubleObj); IsNotComplexType(doubleObj); Assert.AreEqual(TestDouble, doubleObj.Double); SKONObject booleanObj = listObj[4]; IsNotEmpty(booleanObj); IsNotComplexType(booleanObj); Assert.AreEqual(TestBoolean, booleanObj.Boolean); SKONObject dateTimeObj = listObj[5]; IsNotEmpty(dateTimeObj); IsNotComplexType(dateTimeObj); Assert.AreEqual(TestDateTime, dateTimeObj.DateTime); }
void value(out SKONObject skonObject) { skonObject = null; switch (la.kind) { case 12: { Get(); skonObject = new SKONObject(ParserUtils.EscapeString(t.val.Substring(1, t.val.Length - 2))); break; } case 14: { Get(); skonObject = new SKONObject(int.Parse(t.val)); break; } case 15: { Get(); skonObject = new SKONObject(double.Parse(t.val, CultureInfo.InvariantCulture)); break; } case 16: { Get(); skonObject = new SKONObject(ParseDatetime(t.val)); break; } case 4: { skon_map(out skonObject); break; } case 6: { skon_array(out skonObject); break; } case 17: { Get(); skonObject = new SKONObject(true); break; } case 18: { Get(); skonObject = new SKONObject(false); break; } default: SynErr(20); break; } }
public static void HasValue(int expected, SKONObject actual) { Assert.AreEqual(SKONValueType.INTEGER, actual.Type); IsNotEmpty(actual); IsSimpleType(actual); IsNotComplexType(actual); Assert.AreEqual(expected, actual.Int); }
public static void HasValue(double expected, SKONObject actual) { Assert.AreEqual(SKONValueType.FLOAT, actual.Type); IsNotEmpty(actual); IsSimpleType(actual); IsNotComplexType(actual); Assert.AreEqual(expected, actual.Double); }
public static void HasValue(DateTime expected, SKONObject actual) { Assert.AreEqual(SKONValueType.DATETIME, actual.Type); IsNotEmpty(actual); IsSimpleType(actual); IsNotComplexType(actual); Assert.AreEqual(expected, actual.DateTime); }
public static void IsComplexType(SKONObject obj) { Assert.IsTrue(SKONValueType.MAP == obj.Type || SKONValueType.ARRAY == obj.Type); if (obj.Type == SKONValueType.ARRAY) { Assert.GreaterOrEqual(obj.Length, 0); Assert.AreEqual(obj.Values.Count, obj.Length); } Assert.GreaterOrEqual(obj.Keys.Count, 0); }
public static void IsNotComplexType(SKONObject obj) { Assert.AreNotEqual(SKONValueType.MAP, obj.Type); Assert.AreNotEqual(SKONValueType.ARRAY, obj.Type); Assert.AreEqual(-1, obj.Length); Assert.AreEqual(0, obj.Values.Count); Assert.AreEqual(0, obj.Keys.Count); Assert.IsTrue(obj[TestKey].IsEmpty); Assert.IsTrue(obj[0].IsEmpty); }
public static void HasValue(string expected, SKONObject actual) { Assert.AreEqual(SKONValueType.STRING, actual.Type); IsNotEmpty(actual); IsSimpleType(actual); IsNotComplexType(actual); Assert.AreEqual(expected, actual.String); }
public static void HasValue(bool expected, SKONObject actual) { Assert.AreEqual(SKONValueType.BOOLEAN, actual.Type); IsNotEmpty(actual); IsSimpleType(actual); IsNotComplexType(actual); Assert.AreEqual(expected, actual.Boolean); }
void SKON() { Dictionary <string, SKONObject> metadataElements = new Dictionary <string, SKONObject>(); Dictionary <string, SKONObject> mapElements = new Dictionary <string, SKONObject>(); string key; SKONObject value; while (la.kind == 1) { meta_data(out key, out value); } this.metadata = new SKONObject(metadataElements); open_map(out mapElements); this.data = new SKONObject(mapElements); }
public void HardParsing() { string skon = "DifficultTokens: \"_[{]}:;,\", _: 1,__:[\"]\",],"; SKONObject skonObj = ParseWithMetadata(skon); Assert.IsTrue(skonObj.ContainsKey("DifficultTokens")); Assert.IsTrue(skonObj.ContainsKey("_")); Assert.IsTrue(skonObj.ContainsKey("__")); Assert.AreEqual("_[{]}:;,", skonObj["DifficultTokens"].String); Assert.AreEqual(1, skonObj["_"].Int); Assert.AreEqual("]", skonObj["__"][0].String); }
public static void IsNotSimpleType(SKONObject obj) { Assert.AreNotEqual(SKONValueType.STRING, obj.Type); Assert.AreNotEqual(SKONValueType.INTEGER, obj.Type); Assert.AreNotEqual(SKONValueType.FLOAT, obj.Type); Assert.AreNotEqual(SKONValueType.BOOLEAN, obj.Type); Assert.AreNotEqual(SKONValueType.DATETIME, obj.Type); Assert.IsNull(obj.String); Assert.IsNull(obj.Int); Assert.IsNull(obj.Double); Assert.IsNull(obj.Boolean); Assert.IsNull(obj.DateTime); }
public void MapValue() { SKONObject mapObj = TestMap; Assert.AreEqual(SKONValueType.MAP, mapObj.Type); IsNotEmpty(mapObj); IsComplexType(mapObj); IsNotSimpleType(mapObj); Assert.IsTrue(mapObj[TestKey].IsEmpty); Assert.AreEqual(6, mapObj.Keys.Count); Assert.IsTrue(mapObj.ContainsAllKeys("Empty", "String", "Int", "Double", "Bool", "DateTime")); Assert.IsFalse(mapObj.ContainsAllKeys(TestKey)); SKONObject emptyObj = mapObj["Empty"]; IsEmpty(emptyObj); SKONObject stringObj = mapObj["String"]; IsNotEmpty(stringObj); Assert.AreEqual(TestString, stringObj.String); SKONObject intObj = mapObj["Int"]; IsNotEmpty(intObj); Assert.AreEqual(TestInt, intObj.Int); SKONObject doubleObj = mapObj["Double"]; IsNotEmpty(doubleObj); Assert.AreEqual(TestDouble, doubleObj.Double); SKONObject booleanObj = mapObj["Bool"]; IsNotEmpty(booleanObj); Assert.AreEqual(TestBoolean, booleanObj.Boolean); SKONObject dateTimeObj = mapObj["DateTime"]; IsNotEmpty(dateTimeObj); Assert.AreEqual(TestDateTime, dateTimeObj.DateTime); }
public void IntObject() { string intSKON = "IntKey: 1234,"; SKONObject intMap = ParseWithMetadata(intSKON); IsNotEmpty(intMap); IsNotSimpleType(intMap); Assert.IsTrue(intMap.ContainsKey("IntKey")); SKONObject intObj = intMap["IntKey"]; HasValue(1234, intObj); }
public void Test_StringObject() { string stringSKON = "StringKey: \"StringValue\","; SKONObject stringMap = SKON.SKON.Parse(stringSKON); Test_IsNotEmpty(stringMap); Test_NotSimpleType(stringMap); Assert.IsTrue(stringMap.ContainsKey("StringKey")); SKONObject stringObj = stringMap["StringKey"]; TestObject("StringValue", stringObj); }
public void DateTimeObject() { string dateTimeSKON = "DateTimeKey: 1970-01-01,"; SKONObject dateTimeMap = ParseWithMetadata(dateTimeSKON); IsNotEmpty(dateTimeMap); IsNotSimpleType(dateTimeMap); Assert.IsTrue(dateTimeMap.ContainsKey("DateTimeKey")); SKONObject dateTimeObj = dateTimeMap["DateTimeKey"]; HasValue(new DateTime(1970, 01, 01), dateTimeObj); }
public void StringObject() { string stringSKON = "StringKey: \"StringValue\","; SKONObject stringMap = ParseWithMetadata(stringSKON); IsNotEmpty(stringMap); IsNotSimpleType(stringMap); Assert.IsTrue(stringMap.ContainsKey("StringKey")); SKONObject stringObj = stringMap["StringKey"]; HasValue("StringValue", stringObj); }
public void NonReqursiveMapWithEqualMaps() { SKONObject skonObject = SKONObject.GetEmptyMap(); skonObject.Add("test", new List <SKONObject> { new Dictionary <string, SKONObject> { { "test", 1 } }, new Dictionary <string, SKONObject> { { "test", 1 } } }); Assert.IsFalse(SKON.ContainsLoops(skonObject)); Console.WriteLine(SKON.Write(skonObject)); }
public void Test_StringValue() { SKONObject stringObj = new SKONObject(TestString); Assert.AreEqual(SKON.ValueType.STRING, stringObj.Type); Test_IsNotEmpty(stringObj); Assert.IsNull(stringObj.Int); Assert.IsNull(stringObj.Double); Assert.IsNull(stringObj.Boolean); Assert.IsNull(stringObj.DateTime); Assert.AreEqual(TestString, stringObj.String); Test_NotComplexType(stringObj); }
public void Test_IntValue() { SKONObject intObj = new SKONObject(TestInt); Assert.AreEqual(SKON.ValueType.INTEGER, intObj.Type); Test_IsNotEmpty(intObj); Assert.IsNull(intObj.String); Assert.IsNull(intObj.Double); Assert.IsNull(intObj.Boolean); Assert.IsNull(intObj.DateTime); Assert.AreEqual(TestInt, intObj.Int); Test_NotComplexType(intObj); }
public void Test_BooleanValue() { SKONObject booleanObj = new SKONObject(TestBoolean); Assert.AreEqual(SKON.ValueType.BOOLEAN, booleanObj.Type); Test_IsNotEmpty(booleanObj); Assert.IsNull(booleanObj.String); Assert.IsNull(booleanObj.Int); Assert.IsNull(booleanObj.Double); Assert.IsNull(booleanObj.DateTime); Assert.AreEqual(TestBoolean, booleanObj.Boolean); Test_NotComplexType(booleanObj); }
public void Test_DateTimeValue() { SKONObject dateTimeObj = new SKONObject(TestDateTime); Assert.AreEqual(SKON.ValueType.DATETIME, dateTimeObj.Type); Test_IsNotEmpty(dateTimeObj); Assert.IsNull(dateTimeObj.String); Assert.IsNull(dateTimeObj.Int); Assert.IsNull(dateTimeObj.Double); Assert.IsNull(dateTimeObj.Boolean); Assert.AreEqual(TestDateTime, dateTimeObj.DateTime); Test_NotComplexType(dateTimeObj); }
public static void Test_IsNotEmpty(SKONObject obj) { Assert.IsFalse(obj.IsEmpty); bool hasValue = false; hasValue |= obj.String != null; hasValue |= obj.Int != null; hasValue |= obj.Double != null; hasValue |= obj.Boolean != null; hasValue |= obj.DateTime != null; hasValue |= obj.Keys.Count > 0; hasValue |= obj.Values.Count > 0; Assert.IsTrue(hasValue, "SKONObject does not contain any value!"); }
void SKON() { Dictionary <string, SKONObject> mapElements = new Dictionary <string, SKONObject>(); int version; string docVersion; string skema; meta_version(out version); metadata.LanguageVersion = version; meta_docVersion(out docVersion); metadata.DocuemntVersion = docVersion; if (la.kind == 11) { meta_SKEMA(out skema); metadata.SKEMA = skema; } open_map(out mapElements); this.data = new SKONObject(mapElements); }
public void ObjectEqualityOperator() { SKONObject obj1 = new SKONObject(TestString); SKONObject obj2 = new SKONObject(TestString); Assert.IsTrue(obj1 == obj2); Assert.IsTrue(obj1 == TestString); Assert.IsTrue(obj2 == TestString); Assert.IsTrue(obj1.String == TestString); Assert.IsTrue(obj2.String == TestString); float f = 0.4f; Assert.IsFalse(obj1 == f); Assert.IsFalse(obj2 == f); }
public void FloatObject() { string floatSKON = "FloatKey: 1234.5678,"; Console.WriteLine(floatSKON); SKONObject doubleMap = ParseWithMetadata(floatSKON); IsNotEmpty(doubleMap); IsNotSimpleType(doubleMap); Assert.IsTrue(doubleMap.ContainsKey("FloatKey")); SKONObject doubleObj = doubleMap["FloatKey"]; HasValue(1234.5678, doubleObj); }
public void BooleanObject() { string booleanSKON = "BooleanKey: true,"; SKONObject booleanMap = ParseWithMetadata(booleanSKON); Console.WriteLine(SKON.Write(booleanMap)); IsNotEmpty(booleanMap); IsNotSimpleType(booleanMap); Assert.IsTrue(booleanMap.ContainsKey("BooleanKey")); SKONObject booleanObj = booleanMap["BooleanKey"]; HasValue(true, booleanObj); }
public void DoubleValue() { SKONObject doubleObj = new SKONObject(TestDouble); Assert.AreEqual(SKONValueType.FLOAT, doubleObj.Type); IsNotEmpty(doubleObj); Assert.IsNull(doubleObj.String); Assert.IsNull(doubleObj.Int); Assert.IsNull(doubleObj.Boolean); Assert.IsNull(doubleObj.DateTime); Assert.AreEqual(TestDouble, doubleObj.Double); IsSimpleType(doubleObj); IsNotComplexType(doubleObj); }
public static void IsEmpty(SKONObject emptyObj) { Assert.AreEqual(SKONValueType.EMPTY, emptyObj.Type, "Empty SKONObject.Type is not EMPTY!"); Assert.IsTrue(emptyObj.IsEmpty, "Empty SKONObject.IsEmpty returned false!"); Assert.IsNull(emptyObj.String, "Empty SKONObject returned non-null string!"); Assert.IsNull(emptyObj.Int, "Empty SKONObject returned non-null int!"); Assert.IsNull(emptyObj.Double, "Empty SKONObject returned non-null double!"); Assert.IsNull(emptyObj.Boolean, "Empty SKONObject returned non-null boolean!"); Assert.IsNull(emptyObj.DateTime, "Empty SKONObject returned non-null DateTime!"); Assert.AreEqual(-1, emptyObj.Length); Assert.AreEqual(0, emptyObj.Values.Count); Assert.AreEqual(0, emptyObj.Keys.Count); // Should this kind of thing be tested for different keys and indexes? Assert.IsTrue(emptyObj[TestKey].IsEmpty); Assert.IsTrue(emptyObj[0].IsEmpty); }
static void Main(string[] args) { string defaultPath = "./SKONTest.skon"; Console.Write("SKON Input file?:"); string filePath = Console.ReadLine(); if (File.Exists(filePath) == false) { filePath = defaultPath; } SKONObject obj = VerboseParseFile(filePath); Console.WriteLine(); Console.WriteLine(SKON.Write(obj)); Console.ReadKey(true); defaultPath = "./SKEMATest.skema"; Console.Write("SKEMA Input file?:"); filePath = Console.ReadLine(); if (File.Exists(filePath) == false) { filePath = defaultPath; } SKEMAObject skemaObj = VerboseParseFileSKEMA(filePath); Console.WriteLine(); Console.WriteLine(SKEMA.Write(skemaObj)); Console.ReadKey(true); }