Skip to content

Instantly share code, notes, and snippets.

@treeform
Created December 5, 2017 00:06
Show Gist options
  • Save treeform/c140984cf3e69e7c8ed8e76feba5c004 to your computer and use it in GitHub Desktop.
Save treeform/c140984cf3e69e7c8ed8e76feba5c004 to your computer and use it in GitHub Desktop.
import yaml.serialization
import streams
type
TestEntry = object
user_agent_string: string
family: string
major: string
minor: string
patch: string
patch_minor: string
brand: string
model: string
TestFile = object
test_cases: seq[TestEntry]
setDefaultValue(TestEntry, major, "")
setDefaultValue(TestEntry, minor, "")
setDefaultValue(TestEntry, patch, "")
setDefaultValue(TestEntry, patch_minor, "")
setDefaultValue(TestEntry, brand, "")
setDefaultValue(TestEntry, model, "")
var orgTestFile = TestFile()
var s = newFileStream("test_data/test_device.yaml")
load(s, orgTestFile)
s.close()
echo "test --"
var testFile = TestFile()
s = newFileStream("test_data/test_device.yaml")
load(s, testFile)
s.close()
assert orgTestFile.test_cases.len == testFile.test_cases.len
for e in 0..<orgTestFile.test_cases.len:
echo "entry ", e
var e1 = orgTestFile.test_cases[e]
var e2 = testFile.test_cases[e]
assert e1.user_agent_string == e2.user_agent_string
assert e1.family == e2.family
assert e1.major == e2.major
assert e1.patch == e2.patch
assert e1.patch_minor == e2.patch_minor
assert e1.brand == e2.brand
assert e1.model == e2.model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment