DiSMEC++
common_test.cpp File Reference
#include "common.h"
#include "doctest.h"

Go to the source code of this file.

Functions

 TEST_CASE ("check write dense vector")
 
 TEST_CASE ("read dense vector from text")
 
 TEST_CASE ("parse sparse vector")
 
 TEST_CASE ("parse sparse vector errors")
 
 TEST_CASE ("binary dump/load")
 
 TEST_CASE ("parse valid header")
 
 TEST_CASE ("parse invalid header")
 

Function Documentation

◆ TEST_CASE() [1/7]

TEST_CASE ( "binary dump/load"  )
Test:
This test case checks that binary dump and load round-trip data

Definition at line 163 of file common_test.cpp.

References dismec::io::binary_dump(), dismec::io::binary_load(), and dismec::ssize().

◆ TEST_CASE() [2/7]

TEST_CASE ( "check write dense vector"  )
Test:
This checks that vector writing works. It in particular verifies the special cases of 0 and 1-element vectors

Definition at line 15 of file common_test.cpp.

References dismec::io::write_vector_as_text().

◆ TEST_CASE() [3/7]

TEST_CASE ( "parse invalid header"  )
Test:
Check that invalid XMC headers are causing an exception. The headers are invalid if either the number of data does not match, of if any of the supplied counts are non-positive.

Definition at line 196 of file common_test.cpp.

References dismec::io::parse_header().

◆ TEST_CASE() [4/7]

TEST_CASE ( "parse sparse vector errors"  )
Test:
This test checks that XMC sparse vector parsing of invalid lines results in an error. We check the following formatting errors:
  • non-integer index
  • not-a-number
  • missing value with and without space/with and without colon :
  • wrong separator
  • space in front of colon.
  • missing feature index

Definition at line 142 of file common_test.cpp.

References dismec::io::parse_sparse_vector_from_text().

◆ TEST_CASE() [5/7]

TEST_CASE ( "parse sparse vector"  )
Test:
This test checks that XMC feature parsing of valid lines gives the correct result. We check robustness to
  • leading spaces
  • space vs tab
  • scientific notation
  • space after separator
  • space after last feature

Definition at line 75 of file common_test.cpp.

References dismec::io::parse_sparse_vector_from_text().

◆ TEST_CASE() [6/7]

TEST_CASE ( "parse valid header"  )
Test:
Checks that valid XMC headers are parsed correctly

Definition at line 177 of file common_test.cpp.

References dismec::io::MatrixHeader::NumCols, dismec::io::MatrixHeader::NumRows, and dismec::io::parse_header().

◆ TEST_CASE() [7/7]

TEST_CASE ( "read dense vector from text"  )
Test:
This checks that reading a dense vector from text works.

Definition at line 42 of file common_test.cpp.

References dismec::io::read_vector_from_text().