Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
Projet3_first_pull_request
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de conteneur
Registre de modèles
Opération
Environnements
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Charles-Henry Bertrand Van Ouytsel
Projet3_first_pull_request
Requêtes de fusion
!581
Project3
Code
Examiner les modifications
Extraire la branche
Télécharger
Correctifs
Diff brut
Ouvert
Project3
stefanelli/projet3_first_pull_request:Project3
vers
master
Vue d'ensemble
28
Validations
66
Pipelines
28
Modifications
14
Ouvert
Giovanna Stefanelli
a demandé de fusionner
stefanelli/projet3_first_pull_request:Project3
vers
master
5 years ago
Vue d'ensemble
10
Validations
66
Pipelines
28
Modifications
14
Étendre
0
0
Rapports de requête de fusion
Comparer
master
version 27
88a059f5
5 years ago
version 26
2d05a946
5 years ago
version 25
b53ae639
5 years ago
version 24
304f18f6
5 years ago
version 23
b4def6eb
5 years ago
version 22
fc659c55
5 years ago
version 21
0de5c673
5 years ago
version 20
77f71400
5 years ago
version 19
bcc028b3
5 years ago
version 18
322ca4e7
5 years ago
version 17
2ad622c0
5 years ago
version 16
7bdb587f
5 years ago
version 15
14040ae8
5 years ago
version 14
fb416ed8
5 years ago
version 13
db767cca
5 years ago
version 12
25aabebd
5 years ago
version 11
4f38085c
5 years ago
version 10
f974e601
5 years ago
version 9
81fbb0fd
5 years ago
version 8
a2316cfa
5 years ago
version 7
36f2e6ac
5 years ago
version 6
8807ffb2
5 years ago
version 5
bc1a831d
5 years ago
version 4
1fcffb18
5 years ago
version 3
40ec5328
5 years ago
version 2
dcf7f36e
5 years ago
version 1
756dfc36
5 years ago
master (base)
et
version 10
dernière version
9ca268ce
66 validations,
5 years ago
version 27
88a059f5
65 validations,
5 years ago
version 26
2d05a946
64 validations,
5 years ago
version 25
b53ae639
63 validations,
5 years ago
version 24
304f18f6
62 validations,
5 years ago
version 23
b4def6eb
61 validations,
5 years ago
version 22
fc659c55
60 validations,
5 years ago
version 21
0de5c673
59 validations,
5 years ago
version 20
77f71400
58 validations,
5 years ago
version 19
bcc028b3
57 validations,
5 years ago
version 18
322ca4e7
56 validations,
5 years ago
version 17
2ad622c0
55 validations,
5 years ago
version 16
7bdb587f
54 validations,
5 years ago
version 15
14040ae8
53 validations,
5 years ago
version 14
fb416ed8
52 validations,
5 years ago
version 13
db767cca
51 validations,
5 years ago
version 12
25aabebd
50 validations,
5 years ago
version 11
4f38085c
49 validations,
5 years ago
version 10
f974e601
48 validations,
5 years ago
version 9
81fbb0fd
47 validations,
5 years ago
version 8
a2316cfa
46 validations,
5 years ago
version 7
36f2e6ac
45 validations,
5 years ago
version 6
8807ffb2
44 validations,
5 years ago
version 5
bc1a831d
43 validations,
5 years ago
version 4
1fcffb18
42 validations,
5 years ago
version 3
40ec5328
41 validations,
5 years ago
version 2
dcf7f36e
40 validations,
5 years ago
version 1
756dfc36
39 validations,
5 years ago
14 fichiers
+
1754
−
1
En ligne
Comparer les modifications
Côte à côte
En ligne
Afficher les modifications des espaces
Afficher un fichier à la fois
Fichiers
14
Rechercher (par ex. *.vue) (Ctrl+P)
Fact_UnitTest.c
0 → 100644
+
151
−
0
Options
//
// Created by Gio on 23/04/2020.
//
/*
* UNIT TEST WITH CUNIT
* Basic Functions:
* 1. is_div
* 2. is_prime
*/
#include
<sys/types.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<math.h>
#include
<stdbool.h>
//#ifndef _CUNIT_BASIC_H
//#define _CUNIT_BASIC_H
#include
"CUnit/CUnit.h"
#include
"CUnit/Basic.h"
/*
* FUNCTIONS UNDER UNIT TEST
*/
bool
is_div
(
unsigned
long
numbr
,
unsigned
long
i
){
if
((
numbr
%
i
)
==
0
)
{
// verify if i is the divider of numbr
return
(
true
);
// i is a divider of numbr
}
else
{
return
(
false
);
// i is not a divider of numbr
}
}
bool
is_prime
(
unsigned
long
nbr
)
{
for
(
unsigned
long
j
=
2
;
j
<=
sqrt
(
nbr
);
j
++
)
{
if
((
nbr
%
j
)
==
0
)
{
// verify if i is the divider of nbr
return
(
false
);
// i is a divider of nbr
}
}
return
(
true
);
// i is a prime number
}
/*
* CUNIT TEST PROGRAMME
*/
#define IMPAIR 666343 // Prime dividers: 89 7487
#define PAIR1 2548
#define PAIR2 26
#define ZERO 0
#define NEGATIVE -56056
#define PRIME1 529973
#define PRIME2 89
void
test_is_div
(
void
)
{
CU_ASSERT_FALSE
(
is_div
(
IMPAIR
,
PAIR1
)
==
false
);
//False
CU_ASSERT_FALSE
(
is_div
(
ZERO
,
PAIR2
)
==
false
);
//False
CU_ASSERT_FALSE
(
is_div
(
PRIME1
,
IMPAIR
)
==
false
);
//False
CU_ASSERT_FALSE
(
is_div
(
NEGATIVE
,
PAIR1
)
==
false
);
//False**
CU_ASSERT_FALSE
(
is_div
(
PRIME1
,
PAIR2
)
==
false
);
//False
CU_ASSERT_TRUE
(
is_div
(
PAIR1
,
PAIR2
)
==
true
);
//True
CU_ASSERT_TRUE
(
is_div
(
IMPAIR
,
PRIME2
)
==
true
);
//True
}
void
test_is_prime
(
void
)
{
CU_ASSERT_FALSE
(
is_prime
(
IMPAIR
)
==
false
);
//False
CU_ASSERT_FALSE
(
is_prime
(
ZERO
)
==
false
);
//False
CU_ASSERT_TRUE
(
is_prime
(
PRIME1
)
==
true
);
//True
CU_ASSERT_FALSE
(
is_prime
(
NEGATIVE
)
==
false
);
//False
CU_ASSERT_FALSE
(
is_prime
(
PAIR1
)
==
false
);
//False
}
/*
* MAIN CUNIT SUITE
*/
/* Pointer to the file used by the tests. */
static
FILE
*
temp_file
=
NULL
;
/*
* The suite initialization function.
* Opens a temporary file used by the tests.
*/
int
init_suite
(
void
)
{
temp_file
=
fopen
(
"test_file.txt"
,
"w+"
);
if
(
temp_file
==
NULL
)
{
return
-
1
;
}
else
{
return
0
;
}
}
/*
* The suite cleanup function.
* Closes the temporary file used by the tests.
*/
int
clean_suite
(
void
)
{
if
(
fclose
(
temp_file
)
!=
0
)
{
return
-
1
;
}
else
{
temp_file
=
NULL
;
return
0
;
}
}
int
main
()
{
CU_pSuite
pSuite
=
NULL
;
//CU_pSuite pSuite2 = NULL;
/* Initialise CUnit test registry */
if
(
CU_initialize_registry
()
!=
CUE_SUCCESS
)
{
return
(
CU_get_error
());
}
/*
* Add suite1 to registry
*/
pSuite
=
CU_add_suite
(
"Basic_Test_Suite1"
,
init_suite
,
clean_suite
);
if
(
pSuite
==
NULL
)
{
CU_cleanup_registry
();
return
(
CU_get_error
());
}
/*
* add test1 "is_div" to suite1
*/
if
((
CU_add_test
(
pSuite
,
"
\n\n
……… Testing is_div function……..
\n\n
"
,
test_is_div
))
==
NULL
)
{
CU_cleanup_registry
();
return
(
CU_get_error
());
}
/*
* add test1 "is_prime" to suite1
*/
if
((
CU_add_test
(
pSuite
,
"
\n\n
……… Testing is_prime function……..
\n\n
"
,
test_is_prime
))
==
NULL
)
{
CU_cleanup_registry
();
return
(
CU_get_error
());
}
/*
* Run all tests using the CUnit Basic interface
* and provide output to the screen
* Finally clean the registry
*/
CU_basic_set_mode
(
CU_BRM_VERBOSE
);
CU_basic_run_tests
();
CU_cleanup_registry
();
return
(
CU_get_error
());
}
\ No newline at end of file
Chargement en cours