Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 22 12:11
    COLAMAroro edited #342
  • Feb 22 10:55
    COLAMAroro opened #342
  • Feb 20 11:40
    Snaipe commented #341
  • Feb 13 03:47
    bcbcarl opened #341
  • Feb 04 10:19
    1t3x closed #340
  • Feb 04 10:18
    1t3x opened #340
  • Jan 31 22:30
    BSFishy opened #339
  • Jan 27 19:45
    BSFishy commented #338
  • Jan 27 18:52
    BSFishy opened #338
  • Jan 10 14:41
    Snaipe commented #336
  • Jan 10 09:11
    Bensuperpc closed #335
  • Jan 10 09:10
    Bensuperpc commented #335
  • Jan 10 07:58
    hydrapolic commented #336
  • Jan 10 06:51
    kugel- commented #336
  • Jan 10 05:56
    Snaipe commented #333
  • Jan 09 23:55
    Snaipe commented #223
  • Jan 09 23:52
    Snaipe commented #335
  • Jan 09 23:45
    hydrapolic commented #336
  • Jan 09 23:44
    hydrapolic commented #337
  • Jan 09 23:31
    Snaipe closed #337
Franklin Mathieu
@Snaipe
so, in your case, it always returns NULL
Douman
@DoumanAsh
aha... so that's why
Franklin Mathieu
@Snaipe
if you need it to return a valid clipboard HANDLE for certain values, I would probably call GetClipboardData before creating the mock, and do something like mmk_when(GetClipboardData(42), .then_return = the_handle)
Douman
@DoumanAsh
Well, i'm testing negative paths of my functions. For positive cases i use simple tests without mocks as there is no need
Btw is it indented that without any mmk_when my test would crash, if by default all mocks return NULL ?
Franklin Mathieu
@Snaipe
sounds like a bug
Douman
@DoumanAsh
I get this assertion failure E:/Downloads/Git/c_plus_plus/lazy-winapi/build/3pp/src/Mimick/src/matcher.c:51: Assertion failed: v__ != NULL
when i jsut remove any mmk_when
Franklin Mathieu
@Snaipe
no mmk_when and 1 mmk_verify, right?
I think mmk_when does some initialization that should have been mirrored in mmk_verify
Douman
@DoumanAsh
yes
hmm... i see, but i suppose it would be better for user to specify mmk_when regardless of default return value. Just this assertion makes no sense :)
Anyway, mimick is great :) though it is impossible to read compile errors/warnings :D
Franklin Mathieu
@Snaipe
If you're using a GNU compiler, you can reduce the verbosity of compile errors with -isystem=/path/to/mimick/include
Douman
@DoumanAsh
cool, thanks for a tip
Franklin Mathieu
@Snaipe
If you're using a GNU compiler, you can reduce the verbosity of compile errors with -isystem=/path/to/mimick/include
unfortunately I don't think there's a similar trigger for MSVC :/
(also sorry if my messages appear late and/or out of order, I'm on a train)
Douman
@DoumanAsh
well i prefer gcc as MSVC is just bloatware so iti s fine :)
thanks for help, again. Good luck you on your way.
Franklin Mathieu
@Snaipe
No problem, it's the least I can do.
Yuriy Yarosh
@yuriy-yarosh

o/
cr_malloc returns NULL on MacOS, for unknown reason.

Test(uri_tests, emptySchemaShouldBeParsed) {

    URI* testURI = cr_malloc(sizeof(URI));
    cr_log_warn("%u", (uint) sizeof(URI));
    cr_log_error("%u", (uint) testURI);
    cr_assert_not_null(testURI, "URI should be allocated");
...

leads to

[WARN] 88
[ERR ] 0
[----] ~/src/.../Tests/uri_test.c:12: Assertion failed: URI should be allocated
[FAIL] uri_tests::emptySchemaShouldBeParsed: (0.00s)
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0
Franklin Mathieu
@Snaipe
cr_malloc is only relevant when allocating memory from outside a test that should be inherited, just use malloc from within the test
Yuriy Yarosh
@yuriy-yarosh
I don't get what "allocating memory from outside" means...
Franklin Mathieu
@Snaipe
From a report hook, basically
Tests run in their own process, cr_malloc is here to ensure that memory allocated in the parent process gets inherited in the child process
Yuriy Yarosh
@yuriy-yarosh
ah... so basically it's better to go for cr_malloc in setup teardown hooks, right ?
I'm like 1.5 hours into Criterion, so I don't really get how things actually work in here.
Franklin Mathieu
@Snaipe
setup and teardown are run in the same process as the child, so no; I'm talking about things like ReportHook(PRE_ALL) {} for instance
so, in this case, don't worry about it; just use normal malloc and free
Yuriy Yarosh
@yuriy-yarosh

Ok, I'll get into it later.

Anyway, Thank You Franklin for so fast response.

Franklin Mathieu
@Snaipe
You're welcome!
Yuriy Yarosh
@yuriy-yarosh

I'm pretty hyped about Criterion, it's dope. You've did great job.
Writing C+Swift+DPDK backend web-framework, because I can :3
Something like seastar but with a simple API like Vapor

Tried Scala-native previously - it performed not that great...

Franklin Mathieu
@Snaipe
That's awesome! There's still room for a lot of improvements, and I'm rewriting a lot of the core parts for more consistency and simplicity (like #182) for 3.0. Hopefully Criterion will improve even more in the future.
Yuriy Yarosh
@yuriy-yarosh
Yeah, I'll look into it later ;)
Yuriy Yarosh
@yuriy-yarosh
Is it possible to launch Criterion with llvm's Address Sanitizer ?
Franklin Mathieu
@Snaipe
@yuriy-yarosh yes, it should be compatible
even better, the tests aborted by any sanitizer will be marked as a failure
(and you don't need to compile criterion with it, only your tests will work)
Franklin Mathieu
@Snaipe
2.3.1 is out, the full announcement is, as always, here.
Jakob Klepp
@truh
Currently planning for my first bigger C project for college and considering to do some unit testing (it's not required but it seems like a good idea in a team project). Problem is I have not the slightest clue how to make it work with CMake. Could someone point towards a simple project written in C or C++ that uses CMake as a build system and Criterion for testing? Thanks.
Franklin Mathieu
@Snaipe
I don't have one at the top of my head, but let me write a quick one
Jakob Klepp
@truh
Do you have to basically configure a second executable with add_executable?
Franklin Mathieu
@Snaipe
Well, you have to add a new executable for the tests, and then call add_test on it
Jakob Klepp
@truh
Where the second executable doesn't contain your normal main function but instead the test suite?
Franklin Mathieu
@Snaipe
pretty much, although you have to be careful about what you include in the second executable
a cleaner way would be to put your "common" sources in a static/shared lib, and then link that library to your main executable & your tests
if you want to only deal with two executable, you'll have to build your sources twice (once for your main executable, and the other for the tests)
which is going to take some more time
Jakob Klepp
@truh
Does CMake compile stuff twice if it is used by two executables?