#Unit Testing a DLL for C

17 messages · Page 1 of 1 (latest)

spice forge
#

For my Assignment, I need to Unit test my DLL which is compatible in C. Is there an issue with my Setup?

woven shadowBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

#

@spice forge

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

gusty light
#

!f

woven shadowBOT
#

#ifndef TESTSTATUNITTEST_H
#define TESTSTATUNITTEST_H

#include "TextStat.h"
const ```cpp
int TEXTSTAT_DLL_OK = 1;
const int TEXTSTAT_NOT_OK = -1;

// Define type aliases for function pointers
typedef int(__stdcall* TWordCount)(const char* const fileName,
size_t* const numberOfElements);
typedef int(__stdcall* TWordIdentical)(const char* const fileName,
size_t* const numberOfElements,
const char* const checkWord);
typedef int(__stdcall* TWordAverageLength)(const char* const fileName,
size_t* const numberOfElements);
typedef int(__stdcall* TWordSentence)(const char* const fileName,
size_t* const numberOfElements);
typedef int(__stdcall* TDelimiterCount)(const char* const fileName,
size_t* const numberOfElements);

// Function pointers for the DLL functions
extern TWordCount pWordCount;
extern TWordIdentical pWordIdentical;
extern TWordAverageLength pWordAverageLength;
extern TWordSentence pWordSentence;
extern TDelimiterCount pDelimiterCount;


#endif
Simon Lewis
gusty light
#

Your main issue is that GTest is asserting whether a stream is valid, likely either stdin or stdout, which it isn't for some reason, try running your code again, and if it still comes back, check if you're doing anything with stdin, stdout, stderr, std::cout, std::cin, or std::cerr

spice forge
woven shadowBOT
#

@spice forge Has your question been resolved? If so, type !solved :)

spice forge
#

Nope

gusty light
#

The issue is that you’re fclose(pTextFile) when pTextFile is NULL, this then sets off your standard library’s debug validations on whether a valid file pointer is passed to fclose

fiery nest
#

its not a c channel

spice forge
#

How would I test for an empty file in that regard?

spice forge
#

Okay, I think I found the issue. If I close the ticket, can it be reopened later, should I need help or should I just create a neww tickets

elder fiber
spice forge
#

Thank you for telling me that. I cannot believe the error was in plain sight.

Hats off to you

woven shadowBOT
#

@spice forge Has your question been resolved? If so, type !solved :)

spice forge
#

!solved