#Unit Testing a DLL for C
17 messages · Page 1 of 1 (latest)
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
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
!f
#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
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
Hey, thank you for answering my post. I've attached the code for my implementation. I'm returning an integer value in C.
@spice forge Has your question been resolved? If so, type !solved :)
Nope
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
its not a c channel
How would I test for an empty file in that regard?
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
yes it can
forum posts dont get deleted
Thank you for telling me that. I cannot believe the error was in plain sight.
Hats off to you
@spice forge Has your question been resolved? If so, type !solved :)
!solved