diff --git a/Document/README/HowToTest.md b/Document/README/HowToTest.md new file mode 100644 index 0000000..705017d --- /dev/null +++ b/Document/README/HowToTest.md @@ -0,0 +1,28 @@ +# SmartCodable Test + +The current SmartCodable unit test process looks like this: + +The developer's self-test, the demo provides a variety of exhaustive scenarios, will be verified again. +SmartCodable is also used in corporate projects, where business teams test at the functional level. +Each SmartCodable version release will be synchronized to the QQ communication group (group number: 865036731) for online verification. +A major version update of SmartCodable will be released as a beta version for public testing, which can take anywhere from 2 to 4 weeks depending on the size of the feature. + + + +目前SmartCodable的单元测试流程是这样的: + +1. 开发人员的自测,demo中提供的穷举的各种场景,都会验证一遍。 +2. SmartCodable也用在商业项目中,业务团队会进行功能层面的测试。 +3. SmartCodable每次版本发布都会同步到QQ交流群(群号:865036731)做线上验证。 +4. SmartCodable的大版本更新,会发布beta版本,进行公测,根据功能大小,公测时间2~4周不等。 + + + + + +### Build test cases that are as complete as possible + +构建尽可能完善的测试用例。 + + + diff --git a/Document/TestCase.png b/Document/TestCase.png new file mode 100644 index 0000000..2935c92 Binary files /dev/null and b/Document/TestCase.png differ diff --git a/Document/TestCaseSpecification.xmind b/Document/TestCaseSpecification.xmind index 5335b43..30af7e7 100644 Binary files a/Document/TestCaseSpecification.xmind and b/Document/TestCaseSpecification.xmind differ diff --git a/Document/testCase2.png b/Document/testCase2.png new file mode 100644 index 0000000..ab4246c Binary files /dev/null and b/Document/testCase2.png differ diff --git a/Example/SmartCodable/Test3ViewController.swift b/Example/SmartCodable/Test3ViewController.swift index 0d0db4b..0d3febc 100644 --- a/Example/SmartCodable/Test3ViewController.swift +++ b/Example/SmartCodable/Test3ViewController.swift @@ -21,26 +21,27 @@ class Test3ViewController: BaseViewController { let jsonString = """ { - "a": "aa", - "b": 100, - "longitude": "3", - "latitude": 4 + "46": "aa", + "47": 100, } """ if let model = SubModel.deserialize(from: jsonString) { - smartPrint(value: model.c) + smartPrint(value: model) } } - struct SuperModel: SmartCodable { - var longitude: Double? - var latitude: Double? - } + struct SubModel: SmartCodable { - var a: String? - var b: Int? + var a46: String? + var b47: Int? + + + static func mappingForKey() -> [SmartKeyTransformer]? { + [ + CodingKeys.a46 <--- ["1314520", "5201314"], + CodingKeys.b47 <--- "47", + ] + } - @SmartFlat - var c: SuperModel? } } diff --git a/Example/SmartCodable/TestViewController.swift b/Example/SmartCodable/TestViewController.swift index 5bbb03a..c67d7f1 100644 --- a/Example/SmartCodable/TestViewController.swift +++ b/Example/SmartCodable/TestViewController.swift @@ -18,35 +18,21 @@ class TestViewController: BaseViewController { override func viewDidLoad() { super.viewDidLoad() - let jsonString = """ + let jsonStr = """ { - "a": "aa", - "b": 100, - "c": { - "longitude": 300, - "latitude": 400 - }, - - "longitude": 3, - "latitude": 4 + "age": "18", + "weight": "65.4", + "sex": "1" } """ - if let model = SubClass.deserialize(from: jsonString) { - smartPrint(value: model.c) + if let model = ZJSmartCodableModel.deserialize(from: jsonStr) { + smartPrint(value: model) } } - struct SuperClass: SmartCodable { - var longitude: Double? - var latitude: Double? - - var a: String? - var b: Int? - } - struct SubClass: SmartCodable { - var a: String? - var b: Int? - - @SmartFlat - var c: SuperClass? + //模型 + struct ZJSmartCodableModel: SmartCodable { + var age: Int? + var weight: Double? + var sex: Bool? } } diff --git a/README.md b/README.md index 45c5c52..764dace 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,12 @@ If you don't know how to use it, check it out. +## SmarCodable Test + + [👉 To learn more about how SmartCodable is tested, click here]() + + + ## Debug log **SmartLog Error** indicates that **SmartCodable** encountered a resolution problem and executed compatibility logic. This does not mean that the analysis failed.