Skip to content
Snippets Groups Projects
Select Git revision
  • e1d4d354fa9403e37fe1b00d5c1fd8a0347ceca8
  • master default protected
  • ll-wf-finitions
  • ll-workflow
  • b24
  • alc-scindage-donnees-pj
  • FJ_LL_Tbl_Contrat
  • alc-docker-node
  • ll-apiplatform
  • php84
  • ll-rgpd
  • b23
  • alc-filtre-type-intervenant
  • ll-sans-mdb5
  • formules-ancienne-infra
  • ll-formules
  • alc-intervenant-dmep
  • ll-suppr-v_vol-s
  • b20
  • ll-postgresql
  • b23.0.1
  • 24.10
  • 24.9
  • 24.8
  • 24.7
  • 24.6
  • 24.5
  • 24.4
  • 24.3
  • 24.2
  • 24.1
  • 24.0
  • 23.15
  • 24.0-beta19
  • 24.0-beta18
  • 24.0-beta17
  • 24.0-beta16
  • 24.0-beta15
  • 24.0-beta14
  • 24.0-beta13
  • 23.14
41 results

GenDbStructure.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    bignum_tests.c 1.10 KiB
    #include <stdio.h>
    #include <string.h>
    #include <assert.h>
    #include "bignum.h"
    
    #define BG(n) bignum_from_int(n)
    
    void test_arithmetic(){
      assert(bignum_eq(bignum_add(BG(3), BG(4)), BG(7)));
      assert(bignum_eq(bignum_sub(BG(4), BG(3)), BG(1)));
      assert(bignum_eq(bignum_mul(BG(4), BG(3)), BG(12)));
      assert(bignum_eq(bignum_div(BG(36), BG(6)), BG(6)));
      assert(bignum_eq(bignum_mod(BG(21), BG(4)), BG(1)));
      assert(bignum_eq(bignum_pow(BG(2), BG(10)), BG(1024)));
      assert(bignum_eq(bignum_powm(BG(2), BG(10), BG(7)), BG(2)));
      printf("test_arithmetic OK\n");
    }
    
    void test_cmp(){
      assert(bignum_lt(BG(3), BG(42)));
      assert(bignum_lte(BG(3), BG(42)));
      assert(bignum_lte(BG(3), BG(3)));
      assert(!bignum_lte(BG(3), BG(1)));
    
      assert(!bignum_gt(BG(3), BG(42)));
      assert(!bignum_gte(BG(3), BG(42)));
      assert(bignum_gte(BG(3), BG(3)));
      assert(bignum_gte(BG(3), BG(1)));
      
      printf("test_cmp OK\n");
    }
    
    void test_str(){
      assert(strcmp(bignum_to_str(BG(17)), "17") == 0);
      printf("test_str OK\n");
    }
    
    int main(){
      printf("=== BIGNUM tests ===\n");
      test_arithmetic();
      test_cmp();
      test_str();
    
      return 0;
    }