main5.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <glib-object.h>
  4. #include "enums5.h"
  5. #include "meson-sample.h"
  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. /* Make sure that funcs do not have any extra prefix */
  26. if (!meson_the_xenum_get_type())
  27. g_error ("Bad!");
  28. g_type_class_unref(xenum);
  29. g_type_class_unref(flags_enum);
  30. fprintf(stderr, "All ok.\n");
  31. return 0;
  32. }