rodionovd / cegta Goto Github PK
View Code? Open in Web Editor NEWA tiny DSL for TDD/BDD written in C
License: MIT License
A tiny DSL for TDD/BDD written in C
License: MIT License
Sometimes we just want to know whether a test failed or not, without any details.
Something basic like
it("should work with pointers as well", ^{
int *p, *q;
// ...
requirePtr(q, toBe(NULL));
// ...
expectPtr(p, notToBe(NULL));
});
would be enough.
it("foo", ^{
// test foo
});
pending("bar", ^{
// all expectations here will be treated as fulfilled
});
When a "blocking" expectation fails, no other tests within current it()
block will be executed.
Suggested syntax: require()
:
it("should do something with the file <blah>", ^{
int fd = open_particular_file("blah");
require(fd, notToBe(-1));
// if the require() fails, the code below won't be even executed
int err = do_stuff_with_file(fd);
expect(err, toBe(KERN_SUCCESS));
});
expectBoolean(flag, toBe(true));
requireBoolean(flag, notToBe(false));
For integers (the same goes for floating points numbers):
expectInt(foo, toBeLessThan(bar));
expectInt(foo, toBeLessOrEqual(bar));
expectInt(foo, toBeGreaterThan(bar));
for booleans:
expectToBeTrue(foo);
expectToBeFalse(bar);
for strings:
expectString(foo, toContain("bar");
From Specta:
beforeAll(^{
// This is run once and only once before all of the examples
// in this group and before any beforeEach blocks.
});
afterAll(^{
// This is run once and only once after all of the examples
// in this group and after any afterEach blocks.
});
For now it can be done this way:
clock_t tick, tock;
beforeEach(^(const char *it) {
tick = clock();
});
afterEach(^(const char *it) {
fprintf(stderr, "TIME: [%lfs]\n", (double)(tock - tick) / CLOCKS_PER_SEC);
});
it("", ^{
// some heavy stuff here
/// ...
tock = clock();
});
but I want it to be like:
measure_it("blah-blah", ^{
// do something
});
Output:
โ foo blah-blah [0.151462 s]
โฆbecause that's the way things are called in C ๐ฑ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.