test/apiTests.hpp
// Just doing patho tests -- this is heavily function-tested elsewhere.
Just doing patho tests -- this is heavily function-tested elsewhere.
Just doing patho tests -- this is heavily function - tested elsewhere .
TEST(huSerializeTroveToFile, pathological)
{
    auto validFile = "src/test/testFiles/testout.hu";
	int acc = haveAccess(validFile);
    if (acc != -1)
        { remove(validFile); }
    huSerializeOptions params;
    huInitSerializeOptionsZ(& params, HU_WHITESPACEFORMAT_CLONED, 4, false, false, NULL, false, "\n", false);
    huEnumType_t error = HU_ERROR_NOERROR;
    huSize_t fileLen = 0;
    error = huSerializeTroveToFile(NULL, validFile, & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "NULL->file sz == 0");
    acc = haveAccess(validFile);
    LONGS_EQUAL_TEXT(-1, acc, "file does not exist");
    if (acc != -1)
        { remove(validFile); }
    error = huSerializeTroveToFile(HU_NULLTROVE, validFile, & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    error = huSerializeTroveToFile(HU_NULLTROVE, NULL, & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    error = huSerializeTroveToFile(HU_NULLTROVE, "", & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    error = huSerializeTroveToFile(HU_NULLTROVE, "..", & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    error = huSerializeTroveToFile(HU_NULLTROVE, "/", & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    huInitSerializeOptionsZ(& params, 3, 4, false, false, NULL, false, "\n", false);
    error = huSerializeTroveToFile(l.trove, validFile, & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    acc = haveAccess(validFile);
    LONGS_EQUAL_TEXT(-1, acc, "file does not exist");
    if (acc != -1)
        { remove(validFile); }
    huInitSerializeOptionsZ(& params, -1, 4, false, false, NULL, false, "\n", false);
    error = huSerializeTroveToFile(l.trove, validFile, & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    acc = haveAccess(validFile);
    LONGS_EQUAL_TEXT(-1, acc, "file does not exist");
    if (acc != -1)
        { remove(validFile); }
    if (isSignedType(huCol_t))
    {
        huInitSerializeOptionsZ(& params, HU_WHITESPACEFORMAT_CLONED, -1, false, false, NULL, false, "\n", false);
        error = huSerializeTroveToFile(l.trove, validFile, & fileLen, & params);
        LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
        acc = haveAccess(validFile);
        LONGS_EQUAL_TEXT(-1, acc, "file does not exist");
        if (acc != -1)
            { remove(validFile); }
    }
    huInitSerializeOptionsN(& params, HU_WHITESPACEFORMAT_CLONED, 4, false, false, NULL, false, NULL, 1, false);
    error = huSerializeTroveToFile(l.trove, validFile, & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    acc = haveAccess(validFile);
    LONGS_EQUAL_TEXT(-1, acc, "file does not exist");
    if (acc != -1)
        { remove(validFile); }
    huInitSerializeOptionsN(& params, HU_WHITESPACEFORMAT_CLONED, 4, false, true, NULL, false, "\n", 1, false);
    error = huSerializeTroveToFile(l.trove, validFile, & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    acc = haveAccess(validFile);
    LONGS_EQUAL_TEXT(-1, acc, "file does not exist");
    if (acc != -1)
        { remove(validFile); }
    huInitSerializeOptionsN(& params, HU_WHITESPACEFORMAT_PRETTY, 4, false, false, NULL, false, "\n", 0, false);
    error = huSerializeTroveToFile(l.trove, validFile, & fileLen, & params);
    LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
    acc = haveAccess(validFile);
    LONGS_EQUAL_TEXT(-1, acc, "file does not exist");
    if (acc != -1)
        { remove(validFile); }
    if (isSignedType(huSize_t))
    {
        huInitSerializeOptionsN(& params, HU_WHITESPACEFORMAT_CLONED, 4, false, false, NULL, false, "\n", -1, false);
        error = huSerializeTroveToFile(l.trove, validFile, & fileLen, & params);
        LONGS_EQUAL_TEXT(HU_ERROR_BADPARAMETER, error, "null->file sz == 0");
        acc = haveAccess(validFile);
        LONGS_EQUAL_TEXT(-1, acc, "file does not exist");
        if (acc != -1)
            { remove(validFile); }
    }
}
TEST ( huSerializeTroveToFile , pathological ) { auto validFile = " " ; int acc = haveAccess ( validFile ) ; if ( acc != -1 ) { remove ( validFile ) ; } huSerializeOptions params ; huInitSerializeOptionsZ ( & params , HU_WHITESPACEFORMAT_CLONED , 4 , false , false , NULL , false , " \n " , false ) ; huEnumType_t error = HU_ERROR_NOERROR ; huSize_t fileLen = 0 ; error = huSerializeTroveToFile ( NULL , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; acc = haveAccess ( validFile ) ; LONGS_EQUAL_TEXT ( -1 , acc , " " ) ; if ( acc != -1 ) { remove ( validFile ) ; } error = huSerializeTroveToFile ( HU_NULLTROVE , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; error = huSerializeTroveToFile ( HU_NULLTROVE , NULL , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; error = huSerializeTroveToFile ( HU_NULLTROVE , " " , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; error = huSerializeTroveToFile ( HU_NULLTROVE , " " , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; error = huSerializeTroveToFile ( HU_NULLTROVE , " " , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; huInitSerializeOptionsZ ( & params , 3 , 4 , false , false , NULL , false , " \n " , false ) ; error = huSerializeTroveToFile ( l . trove , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; acc = haveAccess ( validFile ) ; LONGS_EQUAL_TEXT ( -1 , acc , " " ) ; if ( acc != -1 ) { remove ( validFile ) ; } huInitSerializeOptionsZ ( & params , -1 , 4 , false , false , NULL , false , " \n " , false ) ; error = huSerializeTroveToFile ( l . trove , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; acc = haveAccess ( validFile ) ; LONGS_EQUAL_TEXT ( -1 , acc , " " ) ; if ( acc != -1 ) { remove ( validFile ) ; } if ( isSignedType ( huCol_t ) ) { huInitSerializeOptionsZ ( & params , HU_WHITESPACEFORMAT_CLONED , -1 , false , false , NULL , false , " \n " , false ) ; error = huSerializeTroveToFile ( l . trove , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; acc = haveAccess ( validFile ) ; LONGS_EQUAL_TEXT ( -1 , acc , " " ) ; if ( acc != -1 ) { remove ( validFile ) ; } } huInitSerializeOptionsN ( & params , HU_WHITESPACEFORMAT_CLONED , 4 , false , false , NULL , false , NULL , 1 , false ) ; error = huSerializeTroveToFile ( l . trove , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; acc = haveAccess ( validFile ) ; LONGS_EQUAL_TEXT ( -1 , acc , " " ) ; if ( acc != -1 ) { remove ( validFile ) ; } huInitSerializeOptionsN ( & params , HU_WHITESPACEFORMAT_CLONED , 4 , false , true , NULL , false , " \n " , 1 , false ) ; error = huSerializeTroveToFile ( l . trove , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; acc = haveAccess ( validFile ) ; LONGS_EQUAL_TEXT ( -1 , acc , " " ) ; if ( acc != -1 ) { remove ( validFile ) ; } huInitSerializeOptionsN ( & params , HU_WHITESPACEFORMAT_PRETTY , 4 , false , false , NULL , false , " \n " , 0 , false ) ; error = huSerializeTroveToFile ( l . trove , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; acc = haveAccess ( validFile ) ; LONGS_EQUAL_TEXT ( -1 , acc , " " ) ; if ( acc != -1 ) { remove ( validFile ) ; } if ( isSignedType ( huSize_t ) ) { huInitSerializeOptionsN ( & params , HU_WHITESPACEFORMAT_CLONED , 4 , false , false , NULL , false , " \n " , -1 , false ) ; error = huSerializeTroveToFile ( l . trove , validFile , & fileLen , & params ) ; LONGS_EQUAL_TEXT ( HU_ERROR_BADPARAMETER , error , " " ) ; acc = haveAccess ( validFile ) ; LONGS_EQUAL_TEXT ( -1 , acc , " " ) ; if ( acc != -1 ) { remove ( validFile ) ; } } }
Just doing patho tests -- this is heavily function-tested elsewhere.
Just doing patho tests -- this is heavily function - tested elsewhere .
// Remove this file if it exists.