Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:42
    Snaipe edited #321
  • 13:29
    Snaipe closed #343
  • 13:29
    Snaipe commented #343
  • 13:27

    Snaipe on bleeding

    meson: fix 'theories' option to… (compare)

  • 13:12

    Snaipe on bleeding

    meson,nanopb: use system lib or… nanopb: upgrade wrap to v0.4.0. nanopb: re-generate protocol fi… (compare)

  • 13:12
    Snaipe closed #333
  • 13:05
    Snaipe commented #344
  • 12:52
    Snaipe commented #347
  • 12:51
    kugel- commented #347
  • 12:50
    Snaipe commented #345
  • 12:45
    Snaipe commented #347
  • Apr 04 12:50
    Snaipe commented #347
  • Mar 30 22:16
    kugel- commented #347
  • Mar 24 11:56
    lgutter commented #345
  • Mar 23 23:46
    kugel- opened #347
  • Mar 22 21:25
    kugel- commented #345
  • Mar 22 15:30
    Snaipe commented #345
  • Mar 22 15:30
    Snaipe commented #345
  • Mar 22 14:33
    kugel- commented #345
  • Mar 22 13:55
    Snaipe commented #345
Franklin Mathieu
@Snaipe
for instance mmk_when(func(1, mmk_le(int, 2)), .then_return = 0) is illegal because you can't mix matchers and non-matchers, so you need to use mmk_eq(int, 1) in this case
and in your case, it doesn't make any difference because by default the mock returns a zero-ish value for unspecified parameters
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)