edhoc 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -0
- package/binding.gyp +13 -11
- package/dist/bindings.d.ts +5 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +10 -0
- package/dist/crypto.d.ts +29 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +205 -0
- package/dist/edhoc.d.ts +368 -0
- package/dist/edhoc.d.ts.map +1 -0
- package/dist/edhoc.js +76 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/x509credentials.d.ts +20 -0
- package/dist/x509credentials.d.ts.map +1 -0
- package/dist/x509credentials.js +140 -0
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
- package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
- package/external/libedhoc/externals/Unity/src/unity.h +698 -0
- package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
- package/external/libedhoc/include/edhoc.h +348 -54
- package/external/libedhoc/include/edhoc_common.h +289 -0
- package/external/libedhoc/include/edhoc_context.h +60 -35
- package/external/libedhoc/include/edhoc_credentials.h +55 -7
- package/external/libedhoc/include/edhoc_crypto.h +10 -10
- package/external/libedhoc/include/edhoc_ead.h +13 -10
- package/external/libedhoc/include/edhoc_macros.h +20 -11
- package/external/libedhoc/include/edhoc_values.h +2 -2
- package/external/libedhoc/library/edhoc.c +70 -36
- package/external/libedhoc/library/edhoc_common.c +1314 -0
- package/external/libedhoc/library/edhoc_exporter.c +45 -46
- package/external/libedhoc/library/edhoc_message_1.c +107 -72
- package/external/libedhoc/library/edhoc_message_2.c +396 -1693
- package/external/libedhoc/library/edhoc_message_3.c +465 -1656
- package/external/libedhoc/library/edhoc_message_4.c +93 -91
- package/external/libedhoc/library/edhoc_message_error.c +41 -41
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
- package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
- package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
- package/external/libedhoc/tests/include/{x509_chain_cs_0/test_vector_x5chain_cs_0.h → test_vector_x5chain_sign_keys_suite_0.h} +137 -140
- package/external/libedhoc/tests/include/{x509_chain_cs_2/test_vector_x5chain_cs_2.h → test_vector_x5chain_sign_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_chain_cs_2_static_dh/test_vector_x5chain_cs_2_static_dh.h → test_vector_x5chain_static_dh_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_hash_cs_2/test_vector_x5t_cs_2.h → test_vector_x5t_sign_keys_suite_2.h} +6 -7
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
- package/external/libedhoc/tests/src/module_test_api.c +430 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
- package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
- package/external/libedhoc/tests/src/module_test_main.c +49 -0
- package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
- package/include/EdhocComposeAsyncWorker.h +8 -6
- package/include/EdhocCredentialManager.h +16 -11
- package/include/EdhocCryptoManager.h +28 -21
- package/include/EdhocEadManager.h +3 -6
- package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
- package/include/EdhocKeyExporterAsyncWorker.h +76 -0
- package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
- package/include/EdhocProcessAsyncWorker.h +14 -10
- package/include/LibEDHOC.h +44 -20
- package/include/UserContext.h +7 -9
- package/include/Utils.h +31 -27
- package/package.json +14 -3
- package/prebuilds/android-arm/edhoc.armv7.node +0 -0
- package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/darwin-arm64/edhoc.node +0 -0
- package/prebuilds/darwin-x64/edhoc.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
- package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
- package/prebuilds/linux-x64/edhoc.musl.node +0 -0
- package/prebuilds/win32-ia32/edhoc.node +0 -0
- package/prebuilds/win32-x64/edhoc.node +0 -0
- package/src/EdhocComposeAsyncWorker.cpp +18 -35
- package/src/EdhocCredentialManager.cpp +160 -187
- package/src/EdhocCryptoManager.cpp +386 -586
- package/src/EdhocEadManager.cpp +10 -18
- package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
- package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
- package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
- package/src/EdhocProcessAsyncWorker.cpp +72 -19
- package/src/LibEDHOC.cpp +213 -174
- package/src/Suites.cpp +39 -72
- package/src/Utils.cpp +32 -56
- package/test/basic.test.ts +64 -0
- package/test/vectors.test.ts +111 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
- package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
- package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
- package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
- package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
- package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
- package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
- package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
- package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
- package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
- package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
- package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
- package/external/libedhoc/tests/src/tests.c +0 -228
- package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
- package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
- package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
- package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
- package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
- package/src/EdhocExportAsyncWorker.cpp +0 -82
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#ifndef UNITY_BDD_TEST_H_
|
|
9
|
+
#define UNITY_BDD_TEST_H_
|
|
10
|
+
|
|
11
|
+
#ifdef __cplusplus
|
|
12
|
+
extern "C"
|
|
13
|
+
{
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#include <stdio.h>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @brief Macros for defining a Behavior-Driven Development (BDD) structure with descriptions.
|
|
20
|
+
*
|
|
21
|
+
* These macros provide a way to structure and describe different phases (Given, When, Then) of a
|
|
22
|
+
* test scenario in a BDD-style format. However, they don't have functional behavior by themselves
|
|
23
|
+
* and are used for descriptive purposes.
|
|
24
|
+
*/
|
|
25
|
+
#define GIVEN(description) \
|
|
26
|
+
if (0) { \
|
|
27
|
+
printf("Given %s\n", description); \
|
|
28
|
+
} else
|
|
29
|
+
|
|
30
|
+
#define WHEN(description) \
|
|
31
|
+
if (0) { \
|
|
32
|
+
printf("When %s\n", description); \
|
|
33
|
+
} else
|
|
34
|
+
|
|
35
|
+
#define THEN(description) \
|
|
36
|
+
if (0) { \
|
|
37
|
+
printf("Then %s\n", description); \
|
|
38
|
+
} else
|
|
39
|
+
|
|
40
|
+
#ifdef __cplusplus
|
|
41
|
+
}
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
#endif
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#include "unity.h"
|
|
9
|
+
#include "unity_bdd.h"
|
|
10
|
+
|
|
11
|
+
void test_bdd_logic_test(void) {
|
|
12
|
+
GIVEN("a valid statement is passed")
|
|
13
|
+
{
|
|
14
|
+
// Set up the context
|
|
15
|
+
bool givenExecuted = true;
|
|
16
|
+
|
|
17
|
+
WHEN("a statement is true")
|
|
18
|
+
{
|
|
19
|
+
// Perform the login action
|
|
20
|
+
bool whenExecuted = true;
|
|
21
|
+
|
|
22
|
+
THEN("we validate everything was worked")
|
|
23
|
+
{
|
|
24
|
+
// Check the expected outcome
|
|
25
|
+
bool thenExecuted = true;
|
|
26
|
+
|
|
27
|
+
TEST_ASSERT_TRUE(givenExecuted);
|
|
28
|
+
TEST_ASSERT_TRUE(whenExecuted);
|
|
29
|
+
TEST_ASSERT_TRUE(thenExecuted);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} // end of case
|
|
34
|
+
|
|
35
|
+
void test_bdd_user_account(void) {
|
|
36
|
+
GIVEN("a user's account with sufficient balance")
|
|
37
|
+
{
|
|
38
|
+
// Set up the context
|
|
39
|
+
float accountBalance = 500.0;
|
|
40
|
+
float withdrawalAmount = 200.0;
|
|
41
|
+
|
|
42
|
+
WHEN("the user requests a withdrawal of $200")
|
|
43
|
+
{
|
|
44
|
+
// Perform the withdrawal action
|
|
45
|
+
if (accountBalance >= withdrawalAmount)
|
|
46
|
+
{
|
|
47
|
+
accountBalance -= withdrawalAmount;
|
|
48
|
+
} // end if
|
|
49
|
+
THEN("the withdrawal amount should be deducted from the account balance")
|
|
50
|
+
{
|
|
51
|
+
// Check the expected outcome
|
|
52
|
+
|
|
53
|
+
// Simulate the scenario
|
|
54
|
+
float compareBalance = 500.0;
|
|
55
|
+
TEST_ASSERT_LESS_THAN_FLOAT(accountBalance, compareBalance);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} // end of case
|
|
60
|
+
|
|
61
|
+
void test_bdd_empty_cart(void) {
|
|
62
|
+
GIVEN("a user with an empty shopping cart")
|
|
63
|
+
{
|
|
64
|
+
// Set up the context
|
|
65
|
+
int cartItemCount = 0;
|
|
66
|
+
|
|
67
|
+
WHEN("the user adds a product to the cart")
|
|
68
|
+
{
|
|
69
|
+
// Perform the action of adding a product
|
|
70
|
+
|
|
71
|
+
THEN("the cart item count should increase by 1")
|
|
72
|
+
{
|
|
73
|
+
// Check the expected outcome
|
|
74
|
+
cartItemCount++;
|
|
75
|
+
|
|
76
|
+
TEST_ASSERT_EQUAL_INT(cartItemCount, 1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} // end of case
|
|
81
|
+
|
|
82
|
+
void test_bdd_valid_login(void) {
|
|
83
|
+
GIVEN("a registered user with valid credentials")
|
|
84
|
+
{
|
|
85
|
+
// Set up the context
|
|
86
|
+
const char* validUsername = "user123";
|
|
87
|
+
const char* validPassword = "pass456";
|
|
88
|
+
|
|
89
|
+
WHEN("the user provides correct username and password")
|
|
90
|
+
{
|
|
91
|
+
// Perform the action of user login
|
|
92
|
+
const char* inputUsername = "user123";
|
|
93
|
+
const char* inputPassword = "pass456";
|
|
94
|
+
|
|
95
|
+
THEN("the login should be successful")
|
|
96
|
+
{
|
|
97
|
+
// Check the expected outcome
|
|
98
|
+
// Simulate login validation
|
|
99
|
+
TEST_ASSERT_EQUAL_STRING(inputUsername, validUsername);
|
|
100
|
+
TEST_ASSERT_EQUAL_STRING(inputPassword, validPassword);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
WHEN("the user provides incorrect password")
|
|
105
|
+
{
|
|
106
|
+
// Perform the action of user login
|
|
107
|
+
const char* inputUsername = "user123";
|
|
108
|
+
const char* inputPassword = "wrongpass";
|
|
109
|
+
|
|
110
|
+
THEN("the login should fail with an error message")
|
|
111
|
+
{
|
|
112
|
+
// Check the expected outcome
|
|
113
|
+
// Simulate login validation
|
|
114
|
+
TEST_ASSERT_EQUAL_STRING(inputUsername, validUsername);
|
|
115
|
+
// TEST_ASSERT_NOT_EQUAL_STRING(inputPassword, validPassword);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} // end of case
|
|
120
|
+
|
|
121
|
+
int main(void)
|
|
122
|
+
{
|
|
123
|
+
UnityBegin("test_bdd.c");
|
|
124
|
+
RUN_TEST(test_bdd_logic_test);
|
|
125
|
+
RUN_TEST(test_bdd_user_account);
|
|
126
|
+
RUN_TEST(test_bdd_empty_cart);
|
|
127
|
+
RUN_TEST(test_bdd_valid_login);
|
|
128
|
+
return UnityEnd();
|
|
129
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#include "unity_fixture.h"
|
|
9
|
+
#include "unity_internals.h"
|
|
10
|
+
#include <string.h>
|
|
11
|
+
|
|
12
|
+
struct UNITY_FIXTURE_T UnityFixture;
|
|
13
|
+
|
|
14
|
+
/* If you decide to use the function pointer approach.
|
|
15
|
+
* Build with -D UNITY_OUTPUT_CHAR=outputChar and include <stdio.h>
|
|
16
|
+
* int (*outputChar)(int) = putchar; */
|
|
17
|
+
|
|
18
|
+
void setUp(void) { /*does nothing*/ }
|
|
19
|
+
void tearDown(void) { /*does nothing*/ }
|
|
20
|
+
|
|
21
|
+
static void announceTestRun(unsigned int runNumber)
|
|
22
|
+
{
|
|
23
|
+
UnityPrint("Unity test run ");
|
|
24
|
+
UnityPrintNumberUnsigned(runNumber+1);
|
|
25
|
+
UnityPrint(" of ");
|
|
26
|
+
UnityPrintNumberUnsigned(UnityFixture.RepeatCount);
|
|
27
|
+
UNITY_PRINT_EOL();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
int UnityMain(int argc, const char* argv[], void (*runAllTests)(void))
|
|
31
|
+
{
|
|
32
|
+
int result = UnityGetCommandLineOptions(argc, argv);
|
|
33
|
+
unsigned int r;
|
|
34
|
+
if (result != 0)
|
|
35
|
+
return result;
|
|
36
|
+
|
|
37
|
+
for (r = 0; r < UnityFixture.RepeatCount; r++)
|
|
38
|
+
{
|
|
39
|
+
UnityBegin(argv[0]);
|
|
40
|
+
announceTestRun(r);
|
|
41
|
+
runAllTests();
|
|
42
|
+
if (!UnityFixture.Verbose) UNITY_PRINT_EOL();
|
|
43
|
+
UnityEnd();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (int)Unity.TestFailures;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static int selected(const char* filter, const char* name)
|
|
50
|
+
{
|
|
51
|
+
if (filter == 0)
|
|
52
|
+
return 1;
|
|
53
|
+
return strstr(name, filter) ? 1 : 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static int testSelected(const char* test)
|
|
57
|
+
{
|
|
58
|
+
return selected(UnityFixture.NameFilter, test);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static int groupSelected(const char* group)
|
|
62
|
+
{
|
|
63
|
+
return selected(UnityFixture.GroupFilter, group);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void UnityTestRunner(unityfunction* setup,
|
|
67
|
+
unityfunction* testBody,
|
|
68
|
+
unityfunction* teardown,
|
|
69
|
+
const char* printableName,
|
|
70
|
+
const char* group,
|
|
71
|
+
const char* name,
|
|
72
|
+
const char* file,
|
|
73
|
+
unsigned int line)
|
|
74
|
+
{
|
|
75
|
+
if (testSelected(name) && groupSelected(group))
|
|
76
|
+
{
|
|
77
|
+
Unity.TestFile = file;
|
|
78
|
+
Unity.CurrentTestName = printableName;
|
|
79
|
+
Unity.CurrentTestLineNumber = line;
|
|
80
|
+
if (UnityFixture.Verbose)
|
|
81
|
+
{
|
|
82
|
+
UnityPrint(printableName);
|
|
83
|
+
#ifndef UNITY_REPEAT_TEST_NAME
|
|
84
|
+
Unity.CurrentTestName = NULL;
|
|
85
|
+
#endif
|
|
86
|
+
}
|
|
87
|
+
else if (UnityFixture.Silent)
|
|
88
|
+
{
|
|
89
|
+
/* Do Nothing */
|
|
90
|
+
}
|
|
91
|
+
else
|
|
92
|
+
{
|
|
93
|
+
UNITY_OUTPUT_CHAR('.');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Unity.NumberOfTests++;
|
|
97
|
+
UnityPointer_Init();
|
|
98
|
+
|
|
99
|
+
UNITY_EXEC_TIME_START();
|
|
100
|
+
|
|
101
|
+
if (TEST_PROTECT())
|
|
102
|
+
{
|
|
103
|
+
setup();
|
|
104
|
+
testBody();
|
|
105
|
+
}
|
|
106
|
+
if (TEST_PROTECT())
|
|
107
|
+
{
|
|
108
|
+
teardown();
|
|
109
|
+
}
|
|
110
|
+
if (TEST_PROTECT())
|
|
111
|
+
{
|
|
112
|
+
UnityPointer_UndoAllSets();
|
|
113
|
+
}
|
|
114
|
+
UnityConcludeFixtureTest();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void UnityIgnoreTest(const char* printableName, const char* group, const char* name)
|
|
119
|
+
{
|
|
120
|
+
if (testSelected(name) && groupSelected(group))
|
|
121
|
+
{
|
|
122
|
+
Unity.NumberOfTests++;
|
|
123
|
+
Unity.TestIgnores++;
|
|
124
|
+
if (UnityFixture.Verbose)
|
|
125
|
+
{
|
|
126
|
+
UnityPrint(printableName);
|
|
127
|
+
UNITY_PRINT_EOL();
|
|
128
|
+
}
|
|
129
|
+
else if (UnityFixture.Silent)
|
|
130
|
+
{
|
|
131
|
+
/* Do Nothing */
|
|
132
|
+
}
|
|
133
|
+
else
|
|
134
|
+
{
|
|
135
|
+
UNITY_OUTPUT_CHAR('!');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/*-------------------------------------------------------- */
|
|
141
|
+
/*Automatic pointer restoration functions */
|
|
142
|
+
struct PointerPair
|
|
143
|
+
{
|
|
144
|
+
void** pointer;
|
|
145
|
+
void* old_value;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
static struct PointerPair pointer_store[UNITY_MAX_POINTERS];
|
|
149
|
+
static int pointer_index = 0;
|
|
150
|
+
|
|
151
|
+
void UnityPointer_Init(void)
|
|
152
|
+
{
|
|
153
|
+
pointer_index = 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line)
|
|
157
|
+
{
|
|
158
|
+
if (pointer_index >= UNITY_MAX_POINTERS)
|
|
159
|
+
{
|
|
160
|
+
UNITY_TEST_FAIL(line, "Too many pointers set");
|
|
161
|
+
}
|
|
162
|
+
else
|
|
163
|
+
{
|
|
164
|
+
pointer_store[pointer_index].pointer = pointer;
|
|
165
|
+
pointer_store[pointer_index].old_value = *pointer;
|
|
166
|
+
*pointer = newValue;
|
|
167
|
+
pointer_index++;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
void UnityPointer_UndoAllSets(void)
|
|
172
|
+
{
|
|
173
|
+
while (pointer_index > 0)
|
|
174
|
+
{
|
|
175
|
+
pointer_index--;
|
|
176
|
+
*(pointer_store[pointer_index].pointer) =
|
|
177
|
+
pointer_store[pointer_index].old_value;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
int UnityGetCommandLineOptions(int argc, const char* argv[])
|
|
182
|
+
{
|
|
183
|
+
int i;
|
|
184
|
+
UnityFixture.Verbose = 0;
|
|
185
|
+
UnityFixture.Silent = 0;
|
|
186
|
+
UnityFixture.GroupFilter = 0;
|
|
187
|
+
UnityFixture.NameFilter = 0;
|
|
188
|
+
UnityFixture.RepeatCount = 1;
|
|
189
|
+
|
|
190
|
+
if (argc == 1)
|
|
191
|
+
return 0;
|
|
192
|
+
|
|
193
|
+
for (i = 1; i < argc; )
|
|
194
|
+
{
|
|
195
|
+
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
|
196
|
+
{
|
|
197
|
+
/* Usage */
|
|
198
|
+
UnityPrint("Runs a series of unit tests.");
|
|
199
|
+
UNITY_PRINT_EOL();
|
|
200
|
+
UNITY_PRINT_EOL();
|
|
201
|
+
UnityPrint("When no flag is specified, all tests are run.");
|
|
202
|
+
UNITY_PRINT_EOL();
|
|
203
|
+
UNITY_PRINT_EOL();
|
|
204
|
+
UnityPrint("Optional flags:");
|
|
205
|
+
UNITY_PRINT_EOL();
|
|
206
|
+
UnityPrint(" -v Verbose output: show all tests executed even if they pass");
|
|
207
|
+
UNITY_PRINT_EOL();
|
|
208
|
+
UnityPrint(" -s Silent mode: minimal output showing only test failures");
|
|
209
|
+
UNITY_PRINT_EOL();
|
|
210
|
+
UnityPrint(" -g NAME Only run tests in groups that contain the string NAME");
|
|
211
|
+
UNITY_PRINT_EOL();
|
|
212
|
+
UnityPrint(" -n NAME Only run tests whose name contains the string NAME");
|
|
213
|
+
UNITY_PRINT_EOL();
|
|
214
|
+
UnityPrint(" -r NUMBER Repeatedly run all tests NUMBER times");
|
|
215
|
+
UNITY_PRINT_EOL();
|
|
216
|
+
UnityPrint(" -h, --help Display this help message");
|
|
217
|
+
UNITY_PRINT_EOL();
|
|
218
|
+
UNITY_PRINT_EOL();
|
|
219
|
+
#ifdef UNITY_CUSTOM_HELP_MSG
|
|
220
|
+
/* User-defined help message, e.g. to point to project-specific documentation */
|
|
221
|
+
UnityPrint(UNITY_CUSTOM_HELP_MSG);
|
|
222
|
+
UNITY_PRINT_EOL();
|
|
223
|
+
#else
|
|
224
|
+
/* Default help suffix if a custom one is not defined */
|
|
225
|
+
UnityPrint("More information about Unity: https://www.throwtheswitch.org/unity");
|
|
226
|
+
UNITY_PRINT_EOL();
|
|
227
|
+
#endif
|
|
228
|
+
return 1; /* Exit without running the tests */
|
|
229
|
+
}
|
|
230
|
+
else if (strcmp(argv[i], "-v") == 0)
|
|
231
|
+
{
|
|
232
|
+
UnityFixture.Verbose = 1;
|
|
233
|
+
i++;
|
|
234
|
+
}
|
|
235
|
+
else if (strcmp(argv[i], "-s") == 0)
|
|
236
|
+
{
|
|
237
|
+
UnityFixture.Silent = 1;
|
|
238
|
+
i++;
|
|
239
|
+
}
|
|
240
|
+
else if (strcmp(argv[i], "-g") == 0)
|
|
241
|
+
{
|
|
242
|
+
i++;
|
|
243
|
+
if (i >= argc)
|
|
244
|
+
return 1;
|
|
245
|
+
UnityFixture.GroupFilter = argv[i];
|
|
246
|
+
i++;
|
|
247
|
+
}
|
|
248
|
+
else if (strcmp(argv[i], "-n") == 0)
|
|
249
|
+
{
|
|
250
|
+
i++;
|
|
251
|
+
if (i >= argc)
|
|
252
|
+
return 1;
|
|
253
|
+
UnityFixture.NameFilter = argv[i];
|
|
254
|
+
i++;
|
|
255
|
+
}
|
|
256
|
+
else if (strcmp(argv[i], "-r") == 0)
|
|
257
|
+
{
|
|
258
|
+
UnityFixture.RepeatCount = 2;
|
|
259
|
+
i++;
|
|
260
|
+
if (i < argc)
|
|
261
|
+
{
|
|
262
|
+
if (*(argv[i]) >= '0' && *(argv[i]) <= '9')
|
|
263
|
+
{
|
|
264
|
+
unsigned int digit = 0;
|
|
265
|
+
UnityFixture.RepeatCount = 0;
|
|
266
|
+
while (argv[i][digit] >= '0' && argv[i][digit] <= '9')
|
|
267
|
+
{
|
|
268
|
+
UnityFixture.RepeatCount *= 10;
|
|
269
|
+
UnityFixture.RepeatCount += (unsigned int)argv[i][digit++] - '0';
|
|
270
|
+
}
|
|
271
|
+
i++;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else
|
|
276
|
+
{
|
|
277
|
+
/* ignore unknown parameter */
|
|
278
|
+
i++;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
void UnityConcludeFixtureTest(void)
|
|
285
|
+
{
|
|
286
|
+
if (Unity.CurrentTestIgnored)
|
|
287
|
+
{
|
|
288
|
+
Unity.TestIgnores++;
|
|
289
|
+
UNITY_PRINT_EOL();
|
|
290
|
+
}
|
|
291
|
+
else if (!Unity.CurrentTestFailed)
|
|
292
|
+
{
|
|
293
|
+
if (UnityFixture.Verbose)
|
|
294
|
+
{
|
|
295
|
+
UnityPrint(" ");
|
|
296
|
+
UnityPrint(UnityStrPass);
|
|
297
|
+
UNITY_EXEC_TIME_STOP();
|
|
298
|
+
UNITY_PRINT_EXEC_TIME();
|
|
299
|
+
UNITY_PRINT_EOL();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else /* Unity.CurrentTestFailed */
|
|
303
|
+
{
|
|
304
|
+
Unity.TestFailures++;
|
|
305
|
+
UNITY_PRINT_EOL();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
Unity.CurrentTestFailed = 0;
|
|
309
|
+
Unity.CurrentTestIgnored = 0;
|
|
310
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#ifndef UNITY_FIXTURE_H_
|
|
10
|
+
#define UNITY_FIXTURE_H_
|
|
11
|
+
|
|
12
|
+
#include "unity.h"
|
|
13
|
+
#include "unity_fixture_internals.h"
|
|
14
|
+
|
|
15
|
+
#ifndef UNITY_FIXTURE_NO_EXTRAS
|
|
16
|
+
#include "unity_memory.h"
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
#ifdef __cplusplus
|
|
20
|
+
extern "C"
|
|
21
|
+
{
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#include "unity_internals.h"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
#define TEST_GROUP(group)\
|
|
31
|
+
static const char* TEST_GROUP_##group = #group
|
|
32
|
+
|
|
33
|
+
#define TEST_SETUP(group) void TEST_##group##_SETUP(void);\
|
|
34
|
+
void TEST_##group##_SETUP(void)
|
|
35
|
+
|
|
36
|
+
#define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void);\
|
|
37
|
+
void TEST_##group##_TEAR_DOWN(void)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#define TEST(group, name) \
|
|
41
|
+
void TEST_##group##_##name##_(void);\
|
|
42
|
+
void TEST_##group##_##name##_run(void);\
|
|
43
|
+
void TEST_##group##_##name##_run(void)\
|
|
44
|
+
{\
|
|
45
|
+
UnityTestRunner(TEST_##group##_SETUP,\
|
|
46
|
+
TEST_##group##_##name##_,\
|
|
47
|
+
TEST_##group##_TEAR_DOWN,\
|
|
48
|
+
"TEST(" #group ", " #name ")",\
|
|
49
|
+
TEST_GROUP_##group, #name,\
|
|
50
|
+
__FILE__, __LINE__);\
|
|
51
|
+
}\
|
|
52
|
+
void TEST_##group##_##name##_(void)
|
|
53
|
+
|
|
54
|
+
#define IGNORE_TEST(group, name) \
|
|
55
|
+
void TEST_##group##_##name##_(void);\
|
|
56
|
+
void TEST_##group##_##name##_run(void);\
|
|
57
|
+
void TEST_##group##_##name##_run(void)\
|
|
58
|
+
{\
|
|
59
|
+
UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")", TEST_GROUP_##group, #name);\
|
|
60
|
+
}\
|
|
61
|
+
void TEST_##group##_##name##_(void)
|
|
62
|
+
|
|
63
|
+
/* Call this for each test, insider the group runner */
|
|
64
|
+
#define RUN_TEST_CASE(group, name) \
|
|
65
|
+
{ void TEST_##group##_##name##_run(void);\
|
|
66
|
+
TEST_##group##_##name##_run(); }
|
|
67
|
+
|
|
68
|
+
/* This goes at the bottom of each test file or in a separate c file */
|
|
69
|
+
#define TEST_GROUP_RUNNER(group)\
|
|
70
|
+
void TEST_##group##_GROUP_RUNNER(void);\
|
|
71
|
+
void TEST_##group##_GROUP_RUNNER(void)
|
|
72
|
+
|
|
73
|
+
/* Call this from main */
|
|
74
|
+
#define RUN_TEST_GROUP(group)\
|
|
75
|
+
{ void TEST_##group##_GROUP_RUNNER(void);\
|
|
76
|
+
TEST_##group##_GROUP_RUNNER(); }
|
|
77
|
+
|
|
78
|
+
/* CppUTest Compatibility Macros */
|
|
79
|
+
#ifndef UNITY_EXCLUDE_CPPUTEST_ASSERTS
|
|
80
|
+
/* Sets a pointer and automatically restores it to its old value after teardown */
|
|
81
|
+
#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&(ptr), (void*)(newPointerValue), __LINE__)
|
|
82
|
+
#define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR((expected), (actual))
|
|
83
|
+
#define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual))
|
|
84
|
+
#define FAIL(message) TEST_FAIL_MESSAGE((message))
|
|
85
|
+
#define CHECK(condition) TEST_ASSERT_TRUE((condition))
|
|
86
|
+
#define LONGS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_INT((expected), (actual))
|
|
87
|
+
#define STRCMP_EQUAL(expected, actual) TEST_ASSERT_EQUAL_STRING((expected), (actual))
|
|
88
|
+
#define DOUBLES_EQUAL(expected, actual, delta) TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual))
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
#ifdef __cplusplus
|
|
92
|
+
}
|
|
93
|
+
#endif
|
|
94
|
+
|
|
95
|
+
#endif /* UNITY_FIXTURE_H_ */
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#ifndef UNITY_FIXTURE_INTERNALS_H_
|
|
10
|
+
#define UNITY_FIXTURE_INTERNALS_H_
|
|
11
|
+
|
|
12
|
+
#ifdef __cplusplus
|
|
13
|
+
extern "C"
|
|
14
|
+
{
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
struct UNITY_FIXTURE_T
|
|
18
|
+
{
|
|
19
|
+
int Verbose;
|
|
20
|
+
int Silent;
|
|
21
|
+
unsigned int RepeatCount;
|
|
22
|
+
const char* NameFilter;
|
|
23
|
+
const char* GroupFilter;
|
|
24
|
+
};
|
|
25
|
+
extern struct UNITY_FIXTURE_T UnityFixture;
|
|
26
|
+
|
|
27
|
+
typedef void unityfunction(void);
|
|
28
|
+
void UnityTestRunner(unityfunction* setup,
|
|
29
|
+
unityfunction* testBody,
|
|
30
|
+
unityfunction* teardown,
|
|
31
|
+
const char* printableName,
|
|
32
|
+
const char* group,
|
|
33
|
+
const char* name,
|
|
34
|
+
const char* file, unsigned int line);
|
|
35
|
+
|
|
36
|
+
void UnityIgnoreTest(const char* printableName, const char* group, const char* name);
|
|
37
|
+
int UnityGetCommandLineOptions(int argc, const char* argv[]);
|
|
38
|
+
void UnityConcludeFixtureTest(void);
|
|
39
|
+
|
|
40
|
+
void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line);
|
|
41
|
+
void UnityPointer_UndoAllSets(void);
|
|
42
|
+
void UnityPointer_Init(void);
|
|
43
|
+
#ifndef UNITY_MAX_POINTERS
|
|
44
|
+
#define UNITY_MAX_POINTERS 5
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#ifdef __cplusplus
|
|
48
|
+
}
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
#endif /* UNITY_FIXTURE_INTERNALS_H_ */
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#include "unity_fixture.h"
|
|
9
|
+
|
|
10
|
+
static void runAllTests(void)
|
|
11
|
+
{
|
|
12
|
+
RUN_TEST_GROUP(UnityFixture);
|
|
13
|
+
RUN_TEST_GROUP(UnityCommandOptions);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
int main(int argc, const char* argv[])
|
|
17
|
+
{
|
|
18
|
+
return UnityMain(argc, argv, runAllTests);
|
|
19
|
+
}
|
|
20
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#include "unity_fixture.h"
|
|
10
|
+
|
|
11
|
+
static int data = -1;
|
|
12
|
+
|
|
13
|
+
TEST_GROUP(mygroup);
|
|
14
|
+
|
|
15
|
+
TEST_SETUP(mygroup)
|
|
16
|
+
{
|
|
17
|
+
data = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
TEST_TEAR_DOWN(mygroup)
|
|
21
|
+
{
|
|
22
|
+
data = -1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
TEST(mygroup, test1)
|
|
26
|
+
{
|
|
27
|
+
TEST_ASSERT_EQUAL_INT(0, data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
TEST(mygroup, test2)
|
|
31
|
+
{
|
|
32
|
+
TEST_ASSERT_EQUAL_INT(0, data);
|
|
33
|
+
data = 5;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
TEST(mygroup, test3)
|
|
37
|
+
{
|
|
38
|
+
data = 7;
|
|
39
|
+
TEST_ASSERT_EQUAL_INT(7, data);
|
|
40
|
+
}
|