Skip to content
Snippets Groups Projects
Commit 1a6c24e5 authored by OUMLIL's avatar OUMLIL
Browse files

ll

parent a7abb93a
Branches abdellah
No related tags found
No related merge requests found
No preview for this file type
......@@ -83,19 +83,23 @@ void class_listing(partition_t * p, int classe, FILE * stream, error_code_t *err
for(int i = 0; i < p->capacity; ++i) {
root = search_for_root(p, i, err);
if(root == classe) {
fprintf(stream, "%d ", i);
fprintf(stream, " %d ", i);
}
}
fprintf(stream, "}");
}
/*
void partitions_listing(partition_t *p, FILE * stream, error_code_t * err) {
int * ettiquettes = malloc
}*/
void partitions_listing(partition_t *p, FILE *stream, error_code_t * err) {
fprintf(stream, "{");
for(int i=0; i<(p->capacity) - 1; i++) {
if(p->parent[i] == i) {
class_listing(p, i, stream, err);
fprintf(stream, ",");
}
}
fprintf(stream, "}");
}
void release_partition(partition_t * p) {
......
No preview for this file type
......@@ -111,8 +111,9 @@ BEGIN_TEST_GROUP(partition_test)
release_partition(&p);
}
TEST(lister_partition) {
printf("\n\n\033[7;33m[fusion_normal_case]\033[0m\n");
TEST(class_listing) {
printf("\n\n\033[7;33m[class_listing]\033[0m\n");
int tab[] = {0, 0, 2, 2, 5, 5, 4, 8, 5, 5, 2};
error_code_t err = none;
partition_t p = create_partition(tab, 11, &err);
......@@ -128,7 +129,29 @@ BEGIN_TEST_GROUP(partition_test)
class_listing(&p, 5, file, &err);
fclose(file);
CHECK( 0 == strcmp(buffer, "{4 5 6 7 8 9 }"));
CHECK( 0 == strcmp(buffer, "{ 4 5 6 7 8 9 }"));
class_listing(&p, 5, stdout, &err);
release_partition(&p);
}
TEST(all_partitions_listing) {
printf("\n\n\033[7;33m[all_partitions_listing]\033[0m\n");
int tab[] = {0, 0, 2, 2, 5, 5, 4, 8, 5, 5, 2};
error_code_t err = none;
partition_t p = create_partition(tab, 11, &err);
p.height_array[5] = 3;
p.height_array[2] = 2;
p.height_array[0] = 2;
char buffer[1024];
FILE * file = fmemopen(buffer, 1024, "w");
REQUIRE ( NULL != file);
partitions_listing(&p, file, &err);
fclose(file);
CHECK( 0 == strcmp(buffer, "{{ 0 1 },{ 2 3 10 },{ 4 5 6 7 8 9 },}"));
release_partition(&p);
}
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment