-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds test case for checking the NoteResponseError macro returns the correct results for different JSON messages (#148)
- Loading branch information
1 parent
f0d4c04
commit 1b6c8c8
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*! | ||
* @file NoteTransaction_test.cpp | ||
* | ||
* Written by the Blues Inc. team. | ||
* | ||
* Copyright (c) 2024 Blues Inc. MIT License. Use of this source code is | ||
* governed by licenses granted by the copyright holder including that found in | ||
* the | ||
* <a href="https://github.com/blues/note-c/blob/master/LICENSE">LICENSE</a> | ||
* file. | ||
* | ||
*/ | ||
|
||
#include <catch2/catch_test_macros.hpp> | ||
//#include "fff.h" | ||
|
||
#include "n_lib.h" | ||
#include "test_static.h" | ||
|
||
// DEFINE_FFF_GLOBALS | ||
// FAKE_VALUE_FUNC(bool, NoteReset) | ||
// FAKE_VALUE_FUNC(const char *, noteJSONTransaction, const char *, size_t, char **, uint32_t) | ||
// FAKE_VALUE_FUNC(bool, noteTransactionStart, uint32_t) | ||
// FAKE_VALUE_FUNC(J *, NoteUserAgent) | ||
// FAKE_VALUE_FUNC(bool, crcError, char *, uint16_t) | ||
|
||
|
||
SCENARIO("NoteResponseError") | ||
{ | ||
NoteSetFnDefault(malloc, free, NULL, NULL); | ||
|
||
// // NoteReset's mock should succeed unless the test explicitly instructs | ||
// // it to fail. | ||
// NoteReset_fake.return_val = true; | ||
// noteTransactionStart_fake.return_val = true; | ||
// crcError_fake.return_val = false; | ||
|
||
SECTION("No err field, returns false") { | ||
J* rsp = JParse("{\"test\":\"me\"}"); | ||
//CHECK(rsp == NULL); | ||
CHECK(!(NoteResponseError(rsp))); | ||
JDelete(rsp); | ||
} | ||
|
||
SECTION("Supplying a response with err returns True") { | ||
J* rsp = JParse("{\"err\":\"DFU mode is not yet fully active: starting communications {wait-module} {connecting} {dfu-not-ready}\"}\n"); | ||
bool hasError = NoteResponseError(rsp); | ||
CHECK((hasError ==true && rsp != NULL)); | ||
JDelete(rsp); | ||
} | ||
|
||
} | ||
|