{"id":13628445,"url":"https://github.com/ThrowTheSwitch/Unity","last_synced_at":"2025-04-17T04:31:47.860Z","repository":{"id":2316638,"uuid":"3276860","full_name":"ThrowTheSwitch/Unity","owner":"ThrowTheSwitch","description":"Simple unit testing for C","archived":false,"fork":false,"pushed_at":"2025-03-31T14:04:14.000Z","size":7119,"stargazers_count":4408,"open_issues_count":83,"forks_count":1015,"subscribers_count":164,"default_branch":"master","last_synced_at":"2025-04-09T01:44:41.541Z","etag":null,"topics":["c","unit-testing"],"latest_commit_sha":null,"homepage":"https://ThrowTheSwitch.org","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThrowTheSwitch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"ThrowTheSwitch"}},"created_at":"2012-01-26T19:52:36.000Z","updated_at":"2025-04-08T14:55:50.000Z","dependencies_parsed_at":"2024-01-19T17:45:33.396Z","dependency_job_id":"8c21197d-31aa-4233-8231-382af7a672a6","html_url":"https://github.com/ThrowTheSwitch/Unity","commit_stats":{"total_commits":935,"total_committers":165,"mean_commits":5.666666666666667,"dds":0.7903743315508022,"last_synced_commit":"b175905940e24192aaf57ca2dae9a32cd24f99d8"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThrowTheSwitch%2FUnity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThrowTheSwitch%2FUnity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThrowTheSwitch%2FUnity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThrowTheSwitch%2FUnity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThrowTheSwitch","download_url":"https://codeload.github.com/ThrowTheSwitch/Unity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249315938,"owners_count":21249860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","unit-testing"],"created_at":"2024-08-01T22:00:52.232Z","updated_at":"2025-04-17T04:31:47.073Z","avatar_url":"https://github.com/ThrowTheSwitch.png","language":"C","readme":"# Unity Test ![CI][]\n\n__Copyright (c) 2007 - 2024 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__\n\nWelcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org.\nUnity Test is a unit testing framework built for C, with a focus on working with embedded toolchains.\n\nThis project is made to test code targetting microcontrollers big and small.\nThe core project is a single C file and a pair of headers, allowing it to be added to your existing build setup without too much headache.\nYou may use any compiler you wish, and may use most existing build systems including Make, CMake, etc.\nIf you'd like to leave the hard work to us, you might be interested in Ceedling, a build tool also by ThrowTheSwitch.org.\n\nIf you're new to Unity, we encourage you to tour the [getting started guide][].\n\nYou can also find the [change log][] and [known issues][] in our documentation.\n\n## Getting Started\n\nThe [docs][] folder contains a [getting started guide][] and much more tips about using Unity.\n\n## Unity Assertion Summary\n\nFor the full list, see [UnityAssertionsReference.md][].\n\n### Basic Validity Tests\n\n    TEST_ASSERT_TRUE(condition)\n\nEvaluates whatever code is in condition and fails if it evaluates to false\n\n    TEST_ASSERT_FALSE(condition)\n\nEvaluates whatever code is in condition and fails if it evaluates to true\n\n    TEST_ASSERT(condition)\n\nAnother way of calling `TEST_ASSERT_TRUE`\n\n    TEST_ASSERT_UNLESS(condition)\n\nAnother way of calling `TEST_ASSERT_FALSE`\n\n    TEST_FAIL()\n    TEST_FAIL_MESSAGE(message)\n\nThis test is automatically marked as a failure.\nThe message is output stating why.\n\n### Numerical Assertions: Integers\n\n    TEST_ASSERT_EQUAL_INT(expected, actual)\n    TEST_ASSERT_EQUAL_INT8(expected, actual)\n    TEST_ASSERT_EQUAL_INT16(expected, actual)\n    TEST_ASSERT_EQUAL_INT32(expected, actual)\n    TEST_ASSERT_EQUAL_INT64(expected, actual)\n\nCompare two integers for equality and display errors as signed integers.\nA cast will be performed to your natural integer size so often this can just be used.\nWhen you need to specify the exact size, you can use a specific version.\n\n    TEST_ASSERT_EQUAL_UINT(expected, actual)\n    TEST_ASSERT_EQUAL_UINT8(expected, actual)\n    TEST_ASSERT_EQUAL_UINT16(expected, actual)\n    TEST_ASSERT_EQUAL_UINT32(expected, actual)\n    TEST_ASSERT_EQUAL_UINT64(expected, actual)\n\nCompare two integers for equality and display errors as unsigned integers.\nLike INT, there are variants for different sizes also.\n\n    TEST_ASSERT_EQUAL_HEX(expected, actual)\n    TEST_ASSERT_EQUAL_HEX8(expected, actual)\n    TEST_ASSERT_EQUAL_HEX16(expected, actual)\n    TEST_ASSERT_EQUAL_HEX32(expected, actual)\n    TEST_ASSERT_EQUAL_HEX64(expected, actual)\n\nCompares two integers for equality and display errors as hexadecimal.\nLike the other integer comparisons, you can specify the size... \nhere the size will also effect how many nibbles are shown (for example, `HEX16` will show 4 nibbles).\n\n    TEST_ASSERT_EQUAL(expected, actual)\n\nAnother way of calling TEST_ASSERT_EQUAL_INT\n\n    TEST_ASSERT_INT_WITHIN(delta, expected, actual)\n\nAsserts that the actual value is within plus or minus delta of the expected value.\nThis also comes in size specific variants.\n\n    TEST_ASSERT_GREATER_THAN(threshold, actual)\n\nAsserts that the actual value is greater than the threshold.\nThis also comes in size specific variants.\n\n    TEST_ASSERT_LESS_THAN(threshold, actual)\n\nAsserts that the actual value is less than the threshold.\nThis also comes in size specific variants.\n\n### Arrays\n\n    _ARRAY\n\nYou can append `_ARRAY` to any of these macros to make an array comparison of that type.\nHere you will need to care a bit more about the actual size of the value being checked.\nYou will also specify an additional argument which is the number of elements to compare.\nFor example:\n\n    TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements)\n\n    _EACH_EQUAL\n\nAnother array comparison option is to check that EVERY element of an array is equal to a single expected value.\nYou do this by specifying the EACH_EQUAL macro.\nFor example:\n\n    TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, elements)\n\n### Numerical Assertions: Bitwise\n\n    TEST_ASSERT_BITS(mask, expected, actual)\n\nUse an integer mask to specify which bits should be compared between two other integers.\nHigh bits in the mask are compared, low bits ignored.\n\n    TEST_ASSERT_BITS_HIGH(mask, actual)\n\nUse an integer mask to specify which bits should be inspected to determine if they are all set high.\nHigh bits in the mask are compared, low bits ignored.\n\n    TEST_ASSERT_BITS_LOW(mask, actual)\n\nUse an integer mask to specify which bits should be inspected to determine if they are all set low.\nHigh bits in the mask are compared, low bits ignored.\n\n    TEST_ASSERT_BIT_HIGH(bit, actual)\n\nTest a single bit and verify that it is high.\nThe bit is specified 0-31 for a 32-bit integer.\n\n    TEST_ASSERT_BIT_LOW(bit, actual)\n\nTest a single bit and verify that it is low.\nThe bit is specified 0-31 for a 32-bit integer.\n\n### Numerical Assertions: Floats\n\n    TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)\n    TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual)\n\nAsserts that the actual value is within plus or minus delta of the expected value.\n\n    TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual)\n    TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual)\n\nAsserts that the actual value is NOT within plus or minus delta of the expected value.\n\n    TEST_ASSERT_EQUAL_FLOAT(expected, actual)\n    TEST_ASSERT_EQUAL_DOUBLE(expected, actual)\n\nAsserts that two floating point values are \"equal\" within a small % delta of the expected value.\n\n    TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual)\n    TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual)\n\nAsserts that two floating point values are NOT \"equal\" within a small % delta of the expected value.\n\n    TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual)\n    TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual)\n    TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual)\n    TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual)\n\nAsserts that the actual value is less than or greater than the threshold.\n\nThere are also `LESS_OR_EQUAL` and `GREATER_OR_EQUAL` variations.\nThese obey the same rules for equality as do `TEST_ASSERT_EQUAL_FLOAT` and `TEST_ASSERT_EQUAL_DOUBLE`:\nIf the two values are within a small % delta of the expected value, the assertion will pass.\n\n### String Assertions\n\n    TEST_ASSERT_EQUAL_STRING(expected, actual)\n\nCompare two null-terminate strings.\nFail if any character is different or if the lengths are different.\n\n    TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len)\n\nCompare two strings.\nFail if any character is different, stop comparing after len characters.\n\n    TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message)\n\nCompare two null-terminate strings.\nFail if any character is different or if the lengths are different.\nOutput a custom message on failure.\n\n    TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message)\n\nCompare two strings.\nFail if any character is different, stop comparing after len characters.\nOutput a custom message on failure.\n\n### Pointer Assertions\n\nMost pointer operations can be performed by simply using the integer comparisons above.\nHowever, a couple of special cases are added for clarity.\n\n    TEST_ASSERT_NULL(pointer)\n\nFails if the pointer is not equal to NULL\n\n    TEST_ASSERT_NOT_NULL(pointer)\n\nFails if the pointer is equal to NULL\n\n### Memory Assertions\n\n    TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)\n\nCompare two blocks of memory.\nThis is a good generic assertion for types that can't be coerced into acting like standard types... \nbut since it's a memory compare, you have to be careful that your data types are packed.\n\n### \\_MESSAGE\n\nYou can append `\\_MESSAGE` to any of the macros to make them take an additional argument.\nThis argument is a string that will be printed at the end of the failure strings.\nThis is useful for specifying more information about the problem.\n\n[CI]: https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg\n[getting started guide]: docs/UnityGettingStartedGuide.md\n[change log]: docs/UnityChangeLog.md\n[known issues]: docs/UnityKnownIssues.md\n[docs]: docs/\n[UnityAssertionsReference.md]: docs/UnityAssertionsReference.md\n","funding_links":["https://github.com/sponsors/ThrowTheSwitch"],"categories":["Debug","C","Testing \u0026 Debugging"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThrowTheSwitch%2FUnity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThrowTheSwitch%2FUnity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThrowTheSwitch%2FUnity/lists"}