{"id":40244402,"url":"https://github.com/degawa/fassert","last_synced_at":"2026-01-20T00:06:28.967Z","repository":{"id":159226145,"uuid":"615632655","full_name":"degawa/fassert","owner":"degawa","description":"An extensible assertion library oriented to work with unit testing frameworks for Fortran","archived":false,"fork":false,"pushed_at":"2025-01-04T11:10:22.000Z","size":409,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-04T12:29:36.622Z","etag":null,"topics":["assert","assertion","assertion-library","assertions","assertions-library","fortran","fortran-library","fortran-package-manager","fortran2008","modern-fortran","testing"],"latest_commit_sha":null,"homepage":"","language":"Fortran","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/degawa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2023-03-18T08:02:57.000Z","updated_at":"2025-01-04T11:10:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"2cb71c29-0ef4-4a16-b4f8-226ffb4fd495","html_url":"https://github.com/degawa/fassert","commit_stats":{"total_commits":254,"total_committers":1,"mean_commits":254.0,"dds":0.0,"last_synced_commit":"7dc8b37a87d9b9a8449c862841e06c541f05a17f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/degawa/fassert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/degawa%2Ffassert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/degawa%2Ffassert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/degawa%2Ffassert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/degawa%2Ffassert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/degawa","download_url":"https://codeload.github.com/degawa/fassert/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/degawa%2Ffassert/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28590676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T00:01:37.455Z","status":"ssl_error","status_checked_at":"2026-01-19T23:58:17.328Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["assert","assertion","assertion-library","assertions","assertions-library","fortran","fortran-library","fortran-package-manager","fortran2008","modern-fortran","testing"],"created_at":"2026-01-20T00:06:28.279Z","updated_at":"2026-01-20T00:06:28.960Z","avatar_url":"https://github.com/degawa.png","language":"Fortran","readme":"# fassert\nAn extensible assertion library oriented to work with unit testing frameworks for Fortran\n\n## Motivations\nThere are some assertion libraries and unit test frameworks for Fortran:\n\n- [Assert](https://github.com/sourceryinstitute/assert)\n- [assert-fortran](https://github.com/alecksandr26/assert-fortran)\n- [naturalFRUIT](https://cibinjoseph.github.io/naturalFRUIT/index.html)\n- [pFUnit](https://github.com/Goddard-Fortran-Ecosystem/pFUnit)\n- [test-drive](https://github.com/fortran-lang/test-drive)\n- [TOAST](https://github.com/thomasms/toast)\n- [veggies](https://gitlab.com/everythingfunctional/veggies) and\n[garden](https://gitlab.com/everythingfunctional/garden)\n\nThey are designed to complete on their own. Therefore, extending features, such as supporting user-defined types and changing output messages containing expected and actual values, takes a lot of work.\n\nThis repository aims to provide an extensible assertion library, fassert, that can collaborate with unit testing frameworks.\n\n## Overview\nThe current version of fassert provides 13 assertion procedures.\n\n|       procedure       |                               functionality                               |\n| :-------------------- | :------------------------------------------------------------------------ |\n| `assert_equal`        | checks that an actual value is equal to the expected one                  |\n| `expect_equal`        | checks that an actual value is equal to the expected one                  |\n| `assert_true`         | checks that an actual value is true                                       |\n| `expect_true`         | checks that an actual value is true                                       |\n| `assert_false`        | checks that an actual value is false                                      |\n| `expect_false`        | checks that an actual value is false                                      |\n| `expect_same_shape`   | checks that the actual and expected values have the same shape            |\n| `assert_approx_equal` | checks that an actual value is equal to the expected one within tolerance |\n| `expect_approx_equal` | checks that an actual value is equal to the expected one within tolerance |\n| `assert_char_equal`   | checks that an actual character string is equal to the expected one       |\n| `expect_char_equal`   | checks that an actual character string is equal to the expected one       |\n| `assert_same_type`    | checks that the actual and expected values are the same type              |\n| `expect_same_type`    | checks that the actual and expected values are the same type              |\n\nThe procedures are classified  into two types.\n1. procedures beginning with `assert` immediately error stops the program when the assertion fails.\n1. procedures beginning with `expect` do not stop the program even if the assertion fails and return the assertion status and message through `intent(out)` variables. Those are callable inside `pure` procedures.\n\nSupported types and ranks currently are listed below:\n\n|                    procdure                     |       types        |  rank   |                                        note                                        |\n| :---------------------------------------------- | :----------------- | :------ | :--------------------------------------------------------------------------------- |\n| `assert_equal`,\u003cbr\u003e`expect_equal`               | `integer(int8)`    | 0,1,2,3 | 0 means a scalar variable                                                          |\n|                                                 | `integer(int16)`   | 0,1,2,3 |                                                                                    |\n|                                                 | `integer(int32)`   | 0,1,2,3 |                                                                                    |\n|                                                 | `integer(int64)`   | 0,1,2,3 |                                                                                    |\n|                                                 | `real(real32)`     | 0,1,2,3 | The equality of floating-point numbers is evaluated based on the integers converted from them to have the same bitset. |\n|                                                 | `real(real64)`     | 0,1,2,3 | The default tolerance is 2, which can be specified by means of the preprocessor macro `FASSERT_ULP` at compile time. |\n|                                                 | `real(real128)`    | 0,1,2,3 |                                                                                    |\n|                                                 | `complex(real32)`  | 0,1,2,3 | The equality is evaluated whether both the real and imaginary parts converted to integers are within the tolerance. |\n|                                                 | `complex(real64)`  | 0,1,2,3 |                                                                                    |\n|                                                 | `complex(real128)` | 0,1,2,3 |                                                                                    |\n|                                                 | `logical`          | 0,1,2,3 |                                                                                    |\n|                                                 | `character(*)`     | 0,1,2,3 |                                                                                    |\n|                                                 | user-defined type  | 0,1,2,3 | need to write comparator and message output procedures according to the interfaces |\n| `assert_true`,\u003cbr\u003e`expect_true`                 | `logical`          | 0,1,2,3 |                                                                                    |\n| `assert_false`,\u003cbr\u003e`expect_false`               | `logical`          | 0,1,2,3 |                                                                                    |\n| `assert_approx_equal`,\u003cbr\u003e`expect_approx_equal` | `real(real32)`     | 0,1,2,3 | The equality is evaluated whether the l2 norm of the real and imaginary parts is within the tolerance. |\n|                                                 | `real(real64)`     | 0,1,2,3 |                                                                                    |\n|                                                 | `real(real128)`    | 0,1,2,3 |                                                                                    |\n|                                                 | `complex(real32)`  | 0,1,2,3 |                                                                                    |\n|                                                 | `complex(real64)`  | 0,1,2,3 |                                                                                    |\n|                                                 | `complex(real128)` | 0,1,2,3 |                                                                                    |\n| `assert_char_equal`,\u003cbr\u003e`expect_char_equal`     | `character(*)`     | 0,1,2,3 | The equality is evaluated as whether two characters are equal, including length, with optional case sensitivity. |\n| `assert_same_type`,\u003cbr\u003e`expect_same_type`       | any                | 0,1,2,3 | Any types, including user-defined types, are acceptable. However, a comparison between arrays of different ranks is not possible.|\n| `expect_same_shape`                             | any                | 1,2,3   | Any types, including user-defined types, are acceptable.\u003cbr\u003eThe intended use is to compare array shapes in `assert_equal`/`expect_equal` before comparing those values. |\n\nThe procedures have several optional arguments. `assert_*` procedures have 3 optional logical arguments, `expected_failure`, `verbose`, and `quiet`. Setting `expected_failure` to `.true.`, the procedures assert that the test will fail as expected. `verbose` and `quiet` control the output of the message from the procedures. `expect_*` procedures have the same arguments, excepting `expect_same_shape` which does not have `expected_failure`. In addition, the procedures have `output_message` argument specifying a string to store the output message instead of outputting it to a unit.\n\n### Examples\n- A simple assertion\n\n```Fortran\ncall assert_equal(0 - 1, 1, \"result should be 1 when input 0+1\")\n! FAILED: result should be 1 when input 0+1\n!     Expected: 1\n!     Actual  : -1\n! ERROR STOP\n```\n\n- Retrieving an assertion result and message for collaborating with test-drive\n```Fortran\nuse :: testdrive, only:error_type, check\nlogical :: stat\ncharacter(:), allocatable :: msg\ntype(error_type), allocatable :: error\n\ncall expect_equal(doublify(10), 20, \"it should return 20 when input 10\", stat, output_message=msg)\n! doublify() is the procedure under test.\n! stat = .false.\n! msg = FAILED: it should return 20 when input 10\n!           Expected: 20\n!           Actual  : 0\n\ncall check(error, stat, msg)\n! The error will be caught. test-drive will display output messages below:\n! # Testing: collaboration with testdrive\n!   Starting doublify() should return 20 when input 10 ... (1/1)\n!        ... doublify() should return 20 when input 10 [FAILED]\n!   Message: FAILED: it should return 20 when input 10\n!     Expected: 20\n!     Actual  : 0\n! 1 test(s) failed!\n! ERROR STOP\n```\n\nThe complete example can be found in `example/collab/testdrive.f90`\n\n- An assertion for user-defined types\n```Fortran\ntype(vector2d_type) :: x, y\n\nx = vector2d_type(1d0, 2d0)\ny = vector2d_type(2d0, 1d0)\n\ncall assert_equal(x, y, \"vector x should equal to y\", is_equal_vec2d, output_on_failure_vec2d)\n! FAILED: vector x should equal to y\n!     Expected: [2.00000000,1.00000000]\n!     Actual  : [1.00000000,2.00000000]\n!     Difference:[1.00000000,-1.00000000]\n! ERROR STOP\n```\n\nThe complete example can be found in `example/userDefined/vector2d/vector2d.f90`\n\n## Getting started\n### Requirements\nfassert has been tested only on Windows 10 but may also work on Linux/Mac OS.\nThe compilers and versions listed below have been used to develop fassert.\n\n- A Fortran 2008 compiler\n    - gfortran 11.2 bundled with [quickstart Fortran on Windows](https://github.com/LKedward/quickstart-fortran)\n    - Intel Fortran Classic 2021.5.0 Build 20211109_000000\n    - NAG Fortran 7.1 Build 7117\n- [Fortran Package Manager](https://github.com/fortran-lang/fpm) (fpm) 0.7.0 alpha\n    - fassert is created as an fpm project.\n- [test-drive](https://github.com/fortran-lang/test-drive) 0.4.0\n    - fassert provides an example of a collaboration with test-drive.\n- [FORD](https://github.com/Fortran-FOSS-Programmers/ford) (optional)\n\n### Get the code\nTo get the code, execute the following commnad:\n\n```console\ngit clone https://github.com/degawa/fassert.git\ncd fassert\n```\n\n### Build with fpm\nTo build the library using fpm, execute the following command:\n\n```console\nfpm build\n```\n\nSpecify the preprocessor macro `FASSERT_ULP` to set the tolerance for evaluating the equality of floating-point numbers as follows:\n\n```console\nfpm build --flag \"-DFASSERT_ULP=4\"\n```\n\nThen, install the library using:\n\n```console\nfpm install --prefix path/to/your/libdir\n```\n\n### Running the tests\nTo run the tests for the fassert using fpm, execute the following command:\n\n```console\nfpm test --flag \"-DWITH_QP\"\n```\n\n`WITH_QP` is a preprocessor macro for enabling `real128` types in test-drive, the testing library.\n\n### Reference from your project\nAdd the following `use` statement to modules or procedures calling fassert.\n\n```Fortran\nuse :: fassert\n```\n\nUse the `fassert_kit` module when writing a comparator and message output procedure for supporting user-defined types or extending behavior for supported types.\n```Fortran\nuse :: fassert_kit\n```\n\n### Reference as a fpm project's dependency\nTo use fassert in your fpm project, add the following to the fpm.toml.\n\n```TOML\n[dependencies]\nfassert = {git = \"https://github.com/degawa/fassert.git\"}\n```\n\n## Todo\n- [ ] To translate docstrings from Japanese into English.\n- [x] To support `complex` types.\n- [ ] To support High-ranked arrays.\n- [ ] To add unit tests.\n- [x] To generate codes using fypp.\n- [ ] To add other assertion procedures.\n    - [x] `assert_approx_equal`\n    - [x] `assert_char_equal`\n    - [ ] `assert_not_equal`\n    - [ ] `assert_greater`\n    - [ ] `assert_less`\n    - [ ] `assert_greater_equal`\n    - [ ] `assert_less_equal`\n    - [x] `assert_same_type`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdegawa%2Ffassert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdegawa%2Ffassert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdegawa%2Ffassert/lists"}