Skip to content

Commit c09c047

Browse files
committed
enumeration BUGFIX inverted sorting order
1 parent 7c167f7 commit c09c047

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/plugins_types/enumeration.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ static int
163163
lyplg_type_sort_enum(const struct ly_ctx *UNUSED(ctx), const struct lyd_value *val1,
164164
const struct lyd_value *val2)
165165
{
166-
if (val1->enum_item->value > val2->enum_item->value) {
166+
if (val1->enum_item->value < val2->enum_item->value) {
167167
return -1;
168-
} else if (val1->enum_item->value < val2->enum_item->value) {
168+
} else if (val1->enum_item->value > val2->enum_item->value) {
169169
return 1;
170170
} else {
171171
return 0;

tests/utests/types/enumeration.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ test_plugin_sort(void **state)
108108
v2 = "black";
109109
assert_int_equal(LY_SUCCESS, type->store(UTEST_LYCTX, lysc_type, v2, strlen(v2) * 8,
110110
0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, NULL, &val2, NULL, &err));
111-
assert_true(0 < type->sort(UTEST_LYCTX, &val1, &val2));
111+
assert_true(0 > type->sort(UTEST_LYCTX, &val1, &val2));
112112
assert_int_equal(0, type->sort(UTEST_LYCTX, &val1, &val1));
113-
assert_true(0 > type->sort(UTEST_LYCTX, &val2, &val1));
113+
assert_true(0 < type->sort(UTEST_LYCTX, &val2, &val1));
114114
type->free(UTEST_LYCTX, &val1);
115115
type->free(UTEST_LYCTX, &val2);
116116
}

0 commit comments

Comments
 (0)