1
use std::fs;
2

            
3
use justjson::doc::Document;
4
use justjson::Value;
5

            
6
1
#[test]
7
1
fn suite() {
8
27
    for entry in fs::read_dir("./tests/roundtrip/").unwrap() {
9
27
        let entry = entry.unwrap();
10
27
        let name = entry.file_name();
11
27
        let Some(name) = name.to_str() else { continue; };
12
27
        if name.ends_with(".json") {
13
27
            println!("Testing {name}");
14
27
            let contents = fs::read(entry.path()).unwrap();
15
27
            let value = Value::from_json_bytes(&contents).unwrap();
16
27
            let as_json = value.to_json();
17
27
            assert_eq!(as_json.as_bytes(), contents);
18

            
19
            // Test that Document -> Value conversion works for this value as
20
            // well.
21
27
            let doc = Document::from_json_bytes(&contents).unwrap();
22
27
            assert_eq!(Value::from(doc), value);
23
        }
24
    }
25
1
}