main.c 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<glib-object.h>
  4. #include"meson-sample.h"
  5. #include"@ENUM_FILE@"
  6. int main(int argc, char **argv) {
  7. GEnumClass *xenum = g_type_class_ref(MESON_TYPE_THE_XENUM);
  8. GFlagsClass *flags_enum = g_type_class_ref(MESON_TYPE_THE_FLAGS_ENUM);
  9. if (g_enum_get_value_by_name(xenum, "MESON_THE_XVALUE")->value != MESON_THE_XVALUE) {
  10. fprintf(stderr, "Get MESON_THE_XVALUE by name failed.\n");
  11. return 1;
  12. }
  13. if (g_enum_get_value_by_nick(xenum, "the-xvalue")->value != MESON_THE_XVALUE) {
  14. fprintf(stderr, "Get MESON_THE_XVALUE by nick failed.\n");
  15. return 2;
  16. }
  17. if (g_flags_get_value_by_name(flags_enum, "MESON_THE_FIRST_VALUE")->value != MESON_THE_FIRST_VALUE) {
  18. fprintf(stderr, "Get MESON_THE_FIRST_VALUE by name failed.\n");
  19. return 3;
  20. }
  21. if (g_flags_get_value_by_nick(flags_enum, "the-first-value")->value != MESON_THE_FIRST_VALUE) {
  22. fprintf(stderr, "Get MESON_THE_FIRST_VALUE by nick failed.\n");
  23. return 4;
  24. }
  25. g_type_class_unref(xenum);
  26. g_type_class_unref(flags_enum);
  27. fprintf(stderr, "All ok.\n");
  28. return 0;
  29. }