Skip to content

Commit 3180344

Browse files
committed
Preapre tests for #33
1 parent b582173 commit 3180344

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'2021-10-08':
2+
- code: '300209'
3+
focusstr: ''
4+
- code: '300047'
5+
focusstr: ''
6+
- code: '300970'
7+
focusstr: ''
8+
- code: '300288'
9+
focusstr: ''
10+
'2021-10-11':
11+
- code: '300162'
12+
focusstr: ''
13+
- code: '300209'
14+
focusstr: ''
15+
- code: '300972'
16+
focusstr: ''
17+
- code: '300159'
18+
focusstr: ''
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python3
2+
3+
""" example generated by issue 33 """
4+
5+
import yaml
6+
7+
a_dict = {
8+
'2021-10-08': [{
9+
'code': '300209',
10+
'focusstr': '',
11+
}, {
12+
'code': '300047',
13+
'focusstr': '',
14+
}, {
15+
'code': '300970',
16+
'focusstr': '',
17+
}, {
18+
'code': '300288',
19+
'focusstr': '',
20+
}],
21+
'2021-10-11': [{
22+
'code': '300162',
23+
'focusstr': '',
24+
}, {
25+
'code': '300209',
26+
'focusstr': '',
27+
}, {
28+
'code': '300972',
29+
'focusstr': '',
30+
}, {
31+
'code': '300159',
32+
'focusstr': '',
33+
}]
34+
}
35+
36+
with open("example.yaml", 'w') as f:
37+
yaml.dump(a_dict, f, default_flow_style=False, sort_keys=False)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <vector>
2+
#include <iostream>
3+
#include <cmath>
4+
#include <wsjcpp_yaml.h>
5+
6+
int main() {
7+
WsjcppYaml yaml;
8+
std::string sFilepath = "../../../../src/tests/data-tests/python_yaml_issue_33/example.yaml";
9+
std::string sError;
10+
if (!yaml.loadFromFile(sFilepath, sError)) {
11+
std::cerr << "Error parsing: " << sError << std::endl;
12+
return -1;
13+
}
14+
15+
int ret = 0;
16+
17+
if (!yaml.getRoot()->hasElement("2021-10-08")) {
18+
std::cerr << "Element '2021-10-08' not found" << std::endl;
19+
ret = -1;
20+
}
21+
22+
if (!yaml.getRoot()->hasElement("2021-10-11")) {
23+
std::cerr << "Element '2021-10-08' not found" << std::endl;
24+
ret = -1;
25+
}
26+
27+
// TODO
28+
return -1;
29+
}

0 commit comments

Comments
 (0)