tests FEATURE context options manipulation
@@ -170,10 +170,73 @@ test_searchdirs(void **state)
ly_ctx_destroy(ctx, NULL);
}
+static void
+test_options(void **state)
+{
+ (void) state; /* unused */
+
+ struct ly_ctx *ctx;
+ assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0xffffffff, &ctx));
+
+ /* unset */
+ /* LY_CTX_ALLIMPLEMENTED */
+ assert_int_not_equal(0, ctx->flags & LY_CTX_ALLIMPLEMENTED);
+ ly_ctx_unset_allimplemented(ctx);
+ assert_int_equal(0, ctx->flags & LY_CTX_ALLIMPLEMENTED);
+
+ /* LY_CTX_DISABLE_SEARCHDIRS */
+ assert_int_not_equal(0, ctx->flags & LY_CTX_DISABLE_SEARCHDIRS);
+ ly_ctx_unset_disable_searchdirs(ctx);
+ assert_int_equal(0, ctx->flags & LY_CTX_DISABLE_SEARCHDIRS);
+
+ /* LY_CTX_DISABLE_SEARCHDIR_CWD */
+ assert_int_not_equal(0, ctx->flags & LY_CTX_DISABLE_SEARCHDIR_CWD);
+ ly_ctx_unset_disable_searchdir_cwd(ctx);
+ assert_int_equal(0, ctx->flags & LY_CTX_DISABLE_SEARCHDIR_CWD);
+
+ /* LY_CTX_NOYANGLIBRARY (not possible to unset) */
+ assert_int_not_equal(0, ctx->flags & LY_CTX_NOYANGLIBRARY);
+
+ /* LY_CTX_PREFER_SEARCHDIRS */
+ assert_int_not_equal(0, ctx->flags & LY_CTX_PREFER_SEARCHDIRS);
+ ly_ctx_unset_prefer_searchdirs(ctx);
+ assert_int_equal(0, ctx->flags & LY_CTX_PREFER_SEARCHDIRS);
+
+ /* LY_CTX_TRUSTED */
+ assert_int_not_equal(0, ctx->flags & LY_CTX_TRUSTED);
+ ly_ctx_unset_trusted(ctx);
+ assert_int_equal(0, ctx->flags & LY_CTX_TRUSTED);
+
+ /* set back */
+ /* LY_CTX_ALLIMPLEMENTED */
+ ly_ctx_set_allimplemented(ctx);
+ assert_int_not_equal(0, ctx->flags & LY_CTX_ALLIMPLEMENTED);
+
+ /* LY_CTX_DISABLE_SEARCHDIRS */
+ ly_ctx_set_disable_searchdirs(ctx);
+ assert_int_not_equal(0, ctx->flags & LY_CTX_DISABLE_SEARCHDIRS);
+
+ /* LY_CTX_DISABLE_SEARCHDIR_CWD */
+ ly_ctx_set_disable_searchdir_cwd(ctx);
+ assert_int_not_equal(0, ctx->flags & LY_CTX_DISABLE_SEARCHDIR_CWD);
+
+ /* LY_CTX_PREFER_SEARCHDIRS */
+ ly_ctx_set_prefer_searchdirs(ctx);
+ assert_int_not_equal(0, ctx->flags & LY_CTX_PREFER_SEARCHDIRS);
+
+ /* LY_CTX_TRUSTED */
+ ly_ctx_set_trusted(ctx);
+ assert_int_not_equal(0, ctx->flags & LY_CTX_TRUSTED);
+
+ /* cleanup */
+ ly_ctx_destroy(ctx, NULL);
+}
+
int main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup(test_searchdirs, logger_setup),
+ cmocka_unit_test_setup(test_options, logger_setup),
};
return cmocka_run_group_tests(tests, NULL, NULL);
