# tests

# input: glibmm_own_dep, giomm_own_dep

test_programs = [
# [[dir-name], exe-name, [sources], giomm-example (not just glibmm-example)]
  [['giomm_asyncresult_sourceobject'], 'test', ['main.cc'], true],
  [['giomm_ioerror'], 'test', ['main.cc'], true],
  [['giomm_ioerror_and_iodbuserror'], 'test', ['main.cc'], true],
  [['giomm_listmodel'], 'test', ['main.cc'], true],
  [['giomm_memoryinputstream'], 'test', ['main.cc'], true],
  [['giomm_simple'], 'test', ['main.cc'], true],
  [['giomm_tls_client'], 'test', ['main.cc'], true],
  [['glibmm_base64'], 'test', ['main.cc'], false],
  [['glibmm_binding'], 'test', ['main.cc'], false],
  [['glibmm_bool_arrayhandle'], 'test', ['main.cc'], false],
  [['glibmm_bool_vector'], 'test', ['main.cc'], false],
  [['glibmm_btree'], 'test', ['main.cc'], false],
  [['glibmm_buildfilename'], 'test', ['main.cc'], false],
  [['glibmm_bytearray'], 'test', ['main.cc'], false],
  [['glibmm_date'], 'test', ['main.cc'], false],
  [['glibmm_interface_implementation'], 'test', ['main.cc'], true],
  [['glibmm_interface_move'], 'test', ['main.cc'], false],
  [['glibmm_mainloop'], 'test', ['main.cc'], false],
  [['glibmm_nodetree'], 'test', ['main.cc'], false],
  [['glibmm_null_containerhandle'], 'test', ['main.cc'], true],
  [['glibmm_null_vectorutils'], 'test', ['main.cc'], true],
  [['glibmm_object_move'], 'test', ['main.cc'], false],
  [['glibmm_objectbase_move'], 'test', ['main.cc'], false],
  [['glibmm_refptr'], 'test', ['main.cc'], false],
  [['glibmm_refptr_sigc_bind'], 'test', ['main.cc'], false],
  [['glibmm_ustring_compose'], 'test', ['main.cc'], false],
  [['glibmm_ustring_format'], 'test', ['main.cc'], false],
  [['glibmm_ustring_make_valid'], 'test', ['main.cc'], false],
  [['glibmm_ustring_sprintf'], 'test', ['main.cc'], false],
  [['glibmm_value'], 'test', ['main.cc'], false],
  [['glibmm_valuearray'], 'test', ['main.cc'], false],
  [['glibmm_variant'], 'test', ['main.cc'], false],
  [['glibmm_vector'], 'test', ['main.cc'], true],
  [['glibmm_weakref'], 'test', ['main.cc'], true],
]

thread_dep = dependency('threads')

foreach ex : test_programs
  dir = ''
  foreach dir_part : ex[0]
    dir = dir / dir_part
  endforeach
  ex_name = (dir / ex[1]).underscorify()
  ex_sources = []
  foreach src : ex[2]
    ex_sources += dir / src
  endforeach

  is_multithread = ex[0][0] == 'glibmm_mainloop'
  mm_dep = ex[3] ? giomm_own_dep : glibmm_own_dep

  exe_file = executable(ex_name, ex_sources,
    cpp_args: ['-DGLIBMM_DISABLE_DEPRECATED', '-DGIOMM_DISABLE_DEPRECATED'],
    dependencies: is_multithread ? [mm_dep, thread_dep] : mm_dep,
    implicit_include_directories: false,
    build_by_default: true,
    install: false,
  )

  test(ex_name, exe_file)
endforeach
