npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

picotest.c

v1.2024.3

Published

Picotest is a minimal C89 unit test framework, consisting of a single header file that defines 7 macros.; colinbarry (2020).

Readme

Picotest

Picotest is a minimal C89 unit test framework, consisting of a single header file that defines 7 macros - by colinbarry.

Installation

Run:

$ npm i picotest.c

And then include picotest.h as follows:

#include "node_modules/picotest.c/include/picotest/picotest.h"

Usage

A test is a function containing one or more ASSERT statements. If all such statements evaluate to true, the test has passed. Tests are grouped into suites, where each suite will evaluate the behaviour of one component of your code. Each suite must be defined entirely in a single .c file (although .c files can contain multiple suites.)

DEF_TEST(test_name) prologue that defines a test function.

ASSERT(cond) cond must evaluate to true for the test to have passed. If any conds evaluate to false, the test function is said to have failed.

DEF_SUITE(suite_name) defines a suite of tests.

RUN_TEST(test_name) must appear in the body of a DEF_SUITE. It runs the test of the given name.

DEF_TEST(returns_length_of_a_string)
{
    ASSERT(len("alfa") == 4);
    ASSERT(len("bravo") == 5);
    ASSERT(len("charlie") == 7);
}

DEF_TEST(returns_length_of_an_empty_string)
{
    ASSERT(len("") == 0);
}

DEF_SUITE(strlen)
{
    RUN_TEST(returns_length_of_a_string);
    RUN_TEST(returns_length_of_an_empty_string);
}

A test runner is required to run the test suites.

IMPORT_SUITE(suite_name) imports the suite of the given name into the test runner scope.

BEGIN_TESTS() must be called to initialise the test run (and to declare the passes and failures variables.)

RUN_SUITE(suite_name) executes the given suite, which must previously have been imported with IMPORT_SUITE.

After all tests are runs, passes will contain the number of tests that have passed, and failures the number that have failed.

IMPORT_SUITE(strlen);
IMPORT_SUITE(reverse);

int main(int argc, char **argv)
{
    BEGIN_TESTS();
    RUN_SUITE(strlen);
    RUN_SUITE(reverse);

    printf("\n%i PASSED\n%i FAILED\n", passes, failures);
    return failures == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}

Building the sample

The sample features two test suites, split between two test source files, and a test runner file. The sample project is built with CMake, which can be invoked with the following commands:

cmake -B ./build -DPICOTEST_BUILD_SAMPLE=ON
cmake --build ./build 

And then run the sample with:

./build/sample/sample

ORG