Changeset 03c4b23 in mainline for uspace/app/nav/test/panel.c
- Timestamp:
- 2021-10-15T16:13:21Z (4 years ago)
- Children:
- 9bed565
- Parents:
- fe5c7a1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/test/panel.c
rfe5c7a1 r03c4b23 446 446 } 447 447 448 /** panel_sort() sorts panel entries */ 449 PCUT_TEST(sort) 450 { 451 panel_t *panel; 452 panel_entry_t *entry; 453 errno_t rc; 454 455 rc = panel_create(NULL, true, &panel); 456 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 457 458 rc = panel_entry_append(panel, "b", 1); 459 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 460 461 rc = panel_entry_append(panel, "c", 3); 462 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 463 464 rc = panel_entry_append(panel, "a", 2); 465 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 466 467 rc = panel_sort(panel); 468 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 469 470 entry = panel_first(panel); 471 PCUT_ASSERT_STR_EQUALS("a", entry->name); 472 PCUT_ASSERT_INT_EQUALS(2, entry->size); 473 474 entry = panel_next(entry); 475 PCUT_ASSERT_STR_EQUALS("b", entry->name); 476 PCUT_ASSERT_INT_EQUALS(1, entry->size); 477 478 entry = panel_next(entry); 479 PCUT_ASSERT_STR_EQUALS("c", entry->name); 480 PCUT_ASSERT_INT_EQUALS(3, entry->size); 481 482 panel_destroy(panel); 483 } 484 485 /** panel_entry_ptr_cmp compares two indirectly referenced entries */ 486 PCUT_TEST(entry_ptr_cmp) 487 { 488 panel_t *panel; 489 panel_entry_t *a, *b; 490 int rel; 491 errno_t rc; 492 493 rc = panel_create(NULL, true, &panel); 494 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 495 496 rc = panel_entry_append(panel, "a", 2); 497 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 498 499 rc = panel_entry_append(panel, "b", 1); 500 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 501 502 a = panel_first(panel); 503 PCUT_ASSERT_NOT_NULL(a); 504 b = panel_next(a); 505 PCUT_ASSERT_NOT_NULL(b); 506 507 /* a < b */ 508 rel = panel_entry_ptr_cmp(&a, &b); 509 PCUT_ASSERT_TRUE(rel < 0); 510 511 /* b > a */ 512 rel = panel_entry_ptr_cmp(&b, &a); 513 PCUT_ASSERT_TRUE(rel > 0); 514 515 /* a == a */ 516 rel = panel_entry_ptr_cmp(&a, &a); 517 PCUT_ASSERT_INT_EQUALS(0, rel); 518 519 panel_destroy(panel); 520 } 521 448 522 /** panel_first() returns valid entry or @c NULL as appropriate */ 449 523 PCUT_TEST(first)
Note:
See TracChangeset
for help on using the changeset viewer.