API
 
Loading...
Searching...
No Matches
zaberUtils_test.cpp
Go to the documentation of this file.
1/** \file zaberUtils_test.cpp
2 * \brief Catch2 tests for the zaberUtils in the zaberLowLevel app.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup zaberLowLevel_files
6 */
7
8#include "../../../tests/testXWC.hpp"
9
10#include "../zaberUtils.hpp"
11
12using namespace MagAOX::app;
13
14namespace libXWCTest
15{
16
17/** \addtogroup zaberLowLevel_unit_test
18 * \brief Additional utility tests for the zaberLowLevel application.
19 *
20 * \ingroup application_unit_test
21 */
22
23/// Namespace for `zaberLowLevel` utility unit tests.
24/** \ingroup zaberLowLevel_unit_test
25 */
26namespace zaberLowLevelTest
27{
28
29/// Verify `parseSystemSerial()` extracts axis addresses and serial numbers from a valid response.
30/**
31 * \ingroup zaberLowLevel_unit_test
32 */
33TEST_CASE( "zaberLowLevel utility helpers parse system.serial responses", "[zaberUtils]" )
34{
35 // clang-format off
36 #ifdef ZABERLOWLEVEL_TEST_DOXYGEN_REF
37 parseSystemSerial( *(std::vector<int> *)nullptr, *(std::vector<std::string> *)nullptr, "" );
38 #endif
39 // clang-format on
40
41 std::string tstr = "@01 0 OK IDLE WR 49822@02 0 OK IDLE WR 49820@03 0 OK IDLE WR 49821\n";
42 std::vector<int> address;
43 std::vector<std::string> serial;
44 int rv = parseSystemSerial( address, serial, tstr );
45
46 REQUIRE( rv == 0 );
47 REQUIRE( address[0] == 1 );
48 REQUIRE( address[1] == 2 );
49 REQUIRE( address[2] == 3 );
50
51 REQUIRE( serial[0] == "49822" );
52 REQUIRE( serial[1] == "49820" );
53 REQUIRE( serial[2] == "49821" );
54}
55
56/// Verify `parseSystemSerial()` rejects malformed non-numeric serial tokens.
57/**
58 * \ingroup zaberLowLevel_unit_test
59 */
60TEST_CASE( "zaberLowLevel utility helpers reject malformed system.serial snapshots", "[zaberUtils]" )
61{
62 std::string tstr = "@09 0 OK BUSY --\n";
63 std::vector<int> address;
64 std::vector<std::string> serial;
65 int rv = parseSystemSerial( address, serial, tstr );
66
67 REQUIRE( rv == ZUTILS_E_BADSERIAL );
68}
69
70} // namespace zaberLowLevelTest
71
72} // namespace libXWCTest
TEST_CASE("zaberLowLevel utility helpers parse system.serial responses", "[zaberUtils]")
Verify parseSystemSerial() extracts axis addresses and serial numbers from a valid response.
int parseSystemSerial(std::vector< int > &address, std::vector< std::string > &serial, const std::string &response)
Parse the system.serial query.
Namespace for all libXWC tests.
#define ZUTILS_E_BADSERIAL