Skip to content

Commit

Permalink
Extra tests TP1
Browse files Browse the repository at this point in the history
  • Loading branch information
agonkolgeci committed Mar 15, 2024
1 parent 54cfec8 commit 48619f0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,44 @@ void create_register(){
TEST_ASSERT_(registry->customers[1]->car == car2, "Car 2 is not in the registry");
}

void create_car_extra(){
Car* car = car_create("AUDI", "TT", "TI007");
TEST_ASSERT_(strcmp(car->brand, "AUDI") == 0, "Car brand is not AUDI");
TEST_ASSERT_(strcmp(car->model, "TT") == 0, "Car model is not TT");
TEST_ASSERT_(strcmp(car->license, "TI007") == 0, "Car license is not TI007");
}

void create_customer_extra(){
Customer* customer = customer_create("Jane Doe", "Some Street 321");
TEST_ASSERT_(strcmp(customer->name, "Jane Doe") == 0, "Customer name is not 'Jane Doe'");
TEST_ASSERT_(strcmp(customer->address, "Some Street 321") == 0, "Customer address is not 'Some Street 321'");
}

void create_register_extra(){
Car* car1 = car_create("AUDI", "TT", "TI007");
Car* car2 = car_create("AUDI", "A4", "TI008");
Customer* customer1 = customer_create("John Doe", "Some Street 123");
Customer* customer2 = customer_create("Jane Doe", "Some Street 321");

link_car(car1, customer1);
link_car(car2, customer2);

Customer** customers = (Customer*[]){customer1, customer2};

Registry* registry = registry_create(customers, 2);
TEST_ASSERT_(registry->customers[0] == customer1, "Customer 1 is not in the registry");
TEST_ASSERT_(registry->customers[1] == customer2, "Customer 2 is not in the registry");

TEST_ASSERT_(registry->customers[0]->car == car1, "Car 1 is not in the registry");
TEST_ASSERT_(registry->customers[1]->car == car2, "Car 2 is not in the registry");
}

TEST_LIST = {
{ "create_car", create_car },
{ "create_customer", create_customer },
{ "create_register", create_register },
{ "create_car_extra", create_car_extra },
{ "create_customer_extra", create_customer_extra },
{ "create_register_extra", create_register_extra },
{ NULL, NULL }
};

1 comment on commit 48619f0

@agonkolgeci
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I forgot to pull the extra tests, so I re-committed them instead of merge.

Please sign in to comment.