LCOV - code coverage report
Current view: top level - unit_tests - ut_float.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 36 36
Test Date: 2025-08-24 13:31:38 Functions: 100.0 % 12 12

            Line data    Source code
       1              : #define CLOVE_SUITE_NAME UtilSuite
       2              : 
       3              : #include "clove-unit.h"
       4              : #include "../src/util/float.h"
       5              : 
       6              : // ====================== lengthFloat() ========================//
       7            2 : CLOVE_TEST(lengthFloatZero)
       8              : {
       9            1 :   uint32_t numeratorLength = 0;
      10            1 :   uint32_t denominatorLength = 0;
      11            1 :   lengthFloat(0, &numeratorLength, &denominatorLength);
      12              : 
      13            1 :   CLOVE_UINT_EQ(1, numeratorLength);
      14            1 :   CLOVE_UINT_EQ(0, denominatorLength);
      15              : }
      16              : 
      17            2 : CLOVE_TEST(lengthFloatPositive)
      18              : {
      19            1 :   uint32_t numeratorLength = 0;
      20            1 :   uint32_t denominatorLength = 0;
      21            1 :   lengthFloat(34.1, &numeratorLength, &denominatorLength);
      22              : 
      23            1 :   CLOVE_UINT_EQ(2, numeratorLength);
      24            1 :   CLOVE_UINT_EQ(1, denominatorLength);
      25              : }
      26              : 
      27            2 : CLOVE_TEST(lengthFloatNegative)
      28              : {
      29            1 :   uint32_t numeratorLength = 0;
      30            1 :   uint32_t denominatorLength = 0;
      31            1 :   lengthFloat(-4.1345, &numeratorLength, &denominatorLength);
      32              : 
      33            1 :   CLOVE_UINT_EQ(1, numeratorLength);
      34            1 :   CLOVE_UINT_EQ(4, denominatorLength);
      35              : }
      36              : 
      37            2 : CLOVE_TEST(lengthFloatJustFraction)
      38              : {
      39            1 :   uint32_t numeratorLength = 0;
      40            1 :   uint32_t denominatorLength = 0;
      41            1 :   lengthFloat(0.981, &numeratorLength, &denominatorLength);
      42              : 
      43            2 :   CLOVE_UINT_EQ(0, numeratorLength);
      44            1 :   CLOVE_UINT_EQ(3, denominatorLength);
      45              : }
      46              : 
      47            2 : CLOVE_TEST(lengthFloatJustFractionWithout0)
      48              : {
      49            1 :   uint32_t numeratorLength = 0;
      50            1 :   uint32_t denominatorLength = 0;
      51            1 :   lengthFloat(.981, &numeratorLength, &denominatorLength);
      52              : 
      53            2 :   CLOVE_UINT_EQ(0, numeratorLength);
      54            1 :   CLOVE_UINT_EQ(3, denominatorLength);
      55              : }
      56              : 
      57            2 : CLOVE_TEST(lengthFloatJustNumerator)
      58              : {
      59            1 :   uint32_t numeratorLength = 0;
      60            1 :   uint32_t denominatorLength = 0;
      61            1 :   lengthFloat(981, &numeratorLength, &denominatorLength);
      62              : 
      63            1 :   CLOVE_UINT_EQ(3, numeratorLength);
      64            1 :   CLOVE_UINT_EQ(0, denominatorLength);
      65              : }
        

Generated by: LCOV version 2.0-1