include(CTest)
include(AwsTestHarness)
include(AwsLibFuzzer)
enable_testing()

file(GLOB TEST_HDRS "v3/*.h v5/*.h")
set(TEST_SRC v3/*.c v5/*.c *.c)
file(GLOB TESTS ${TEST_HDRS} ${TEST_SRC})

add_test_case(mqtt_packet_puback)
add_test_case(mqtt_packet_pubrec)
add_test_case(mqtt_packet_pubrel)
add_test_case(mqtt_packet_pubcomp)
add_test_case(mqtt_packet_suback)
add_test_case(mqtt_packet_unsuback)
add_test_case(mqtt_packet_connect)
add_test_case(mqtt_packet_connect_will)
add_test_case(mqtt_packet_connect_empty_payload_will)
add_test_case(mqtt_packet_connect_password)
add_test_case(mqtt_packet_connect_all)
add_test_case(mqtt_packet_connack)
add_test_case(mqtt_packet_publish_qos0_dup)
add_test_case(mqtt_packet_publish_qos2_retain)
add_test_case(mqtt_packet_publish_empty_payload)
add_test_case(mqtt_packet_subscribe)
add_test_case(mqtt_packet_unsubscribe)
add_test_case(mqtt_packet_pingreq)
add_test_case(mqtt_packet_pingresp)
add_test_case(mqtt_packet_disconnect)

add_test_case(mqtt_packet_connack_decode_failure_reserved)
add_test_case(mqtt_packet_ack_decode_failure_reserved)
add_test_case(mqtt_packet_pingresp_decode_failure_reserved)

add_test_case(mqtt_frame_and_decode_publish)
add_test_case(mqtt_frame_and_decode_suback)
add_test_case(mqtt_frame_and_decode_unsuback)
add_test_case(mqtt_frame_and_decode_puback)
add_test_case(mqtt_frame_and_decode_pingresp)
add_test_case(mqtt_frame_and_decode_connack)
add_test_case(mqtt_frame_and_decode_bad_remaining_length)
add_test_case(mqtt_frame_and_decode_unsupported_packet_type)
add_test_case(mqtt_frame_and_decode_bad_flags_for_packet_type)

add_test_case(mqtt_topic_tree_match)
add_test_case(mqtt_topic_tree_unsubscribe)
add_test_case(mqtt_topic_tree_duplicate_transactions)
add_test_case(mqtt_topic_tree_transactions)
add_test_case(mqtt_topic_validation)
add_test_case(mqtt_topic_filter_validation)

add_test_case(mqtt_connect_disconnect)
add_test_case(mqtt_connect_set_will_login)
add_test_case(mqtt_connection_interrupted)
add_test_case(mqtt_connection_any_publish)
add_test_case(mqtt_connection_timeout)
add_test_case(mqtt_connection_connack_timeout)
add_test_case(mqtt_connection_failure_callback)
add_test_case(mqtt_connection_success_callback)
add_test_case(mqtt_connect_subscribe)
add_test_case(mqtt_connect_subscribe_fail_from_broker)
add_test_case(mqtt_connect_subscribe_multi)
add_test_case(mqtt_connect_subscribe_incoming_dup)
add_test_case(mqtt_connect_unsubscribe)
add_test_case(mqtt_connect_resubscribe)
add_test_case(mqtt_connect_publish)
add_test_case(mqtt_connect_publish_payload)
add_test_case(mqtt_connection_offline_publish)
add_test_case(mqtt_connection_disconnect_while_reconnecting)
add_test_case(mqtt_connection_closes_while_making_requests)
add_test_case(mqtt_connection_resend_packets)
# It's too complicate to implement... Let's save it for the future.
# add_test_case(mqtt_connection_not_retry_publish_QoS_0)
add_test_case(mqtt_connection_consistent_retry_policy)
add_test_case(mqtt_connection_not_resend_packets_on_healthy_connection)
add_test_case(mqtt_connection_destory_pending_requests)
add_test_case(mqtt_clean_session_not_retry)
add_test_case(mqtt_clean_session_discard_previous)
add_test_case(mqtt_clean_session_keep_next_session)
add_test_case(mqtt_connection_publish_QoS1_timeout)
add_test_case(mqtt_connection_unsub_timeout)
add_test_case(mqtt_connection_publish_QoS1_timeout_connection_lost_reset_time)
add_test_case(mqtt_connection_ping_norm)
add_test_case(mqtt_connection_ping_no)
add_test_case(mqtt_connection_ping_noack)
add_test_case(mqtt_connection_ping_basic_scenario)
add_test_case(mqtt_connection_ping_double_scenario)
add_test_case(mqtt_connection_close_callback_simple)
add_test_case(mqtt_connection_close_callback_interrupted)
add_test_case(mqtt_connection_close_callback_multi)
add_test_case(mqtt_connection_reconnection_backoff_stable)
add_test_case(mqtt_connection_reconnection_backoff_unstable)
add_test_case(mqtt_connection_reconnection_backoff_reset)
add_test_case(mqtt_connection_reconnection_backoff_reset_after_disconnection)

add_test_case(mqtt_validation_failure_publish_qos)
add_test_case(mqtt_validation_failure_invalid_will_qos)
add_test_case(mqtt_validation_failure_subscribe_empty)
add_test_case(mqtt_validation_failure_unsubscribe_null)
add_test_case(mqtt_validation_failure_connect_invalid_client_id_utf8)
add_test_case(mqtt_validation_failure_invalid_will_topic_utf8)
add_test_case(mqtt_validation_failure_invalid_username_utf8)

# Operation statistics tests
add_test_case(mqtt_operation_statistics_simple_publish)
add_test_case(mqtt_operation_statistics_offline_publish)
add_test_case(mqtt_operation_statistics_disconnect_publish)
add_test_case(mqtt_operation_statistics_reconnect_publish)
add_test_case(mqtt_operation_statistics_simple_subscribe)
add_test_case(mqtt_operation_statistics_simple_unsubscribe)
add_test_case(mqtt_operation_statistics_simple_resubscribe)
add_test_case(mqtt_operation_statistics_simple_callback)

# Connection termination tests
add_test_case(mqtt_connection_termination_callback_simple)

# MQTT5 tests

# topic utilities
add_test_case(mqtt5_topic_skip_rules_prefix)
add_test_case(mqtt5_topic_get_segment_count)
add_test_case(mqtt5_shared_subscription_validation)

# utf8 utility
add_test_case(mqtt_utf8_encoded_string_test)

# topic aliasing
add_test_case(mqtt5_inbound_topic_alias_register_failure)
add_test_case(mqtt5_inbound_topic_alias_resolve_success)
add_test_case(mqtt5_inbound_topic_alias_resolve_failure)
add_test_case(mqtt5_inbound_topic_alias_reset)
add_test_case(mqtt5_outbound_topic_alias_disabled_resolve_success)
add_test_case(mqtt5_outbound_topic_alias_disabled_resolve_failure)
add_test_case(mqtt5_outbound_topic_alias_user_resolve_failure_zero_alias)
add_test_case(mqtt5_outbound_topic_alias_user_resolve_failure_too_big_alias)
add_test_case(mqtt5_outbound_topic_alias_user_resolve_success)
add_test_case(mqtt5_outbound_topic_alias_user_reset)
add_test_case(mqtt5_outbound_topic_alias_lru_zero_size)

# lru topic sequence tests
# cache size of 2
# a, b, c, refer to distinct topics
# the 'r' suffice refers to expected alias reuse
add_test_case(mqtt5_outbound_topic_alias_lru_a_ar)
add_test_case(mqtt5_outbound_topic_alias_lru_b_a_br)
add_test_case(mqtt5_outbound_topic_alias_lru_a_b_ar_br)
add_test_case(mqtt5_outbound_topic_alias_lru_a_b_c_br_cr_br_cr_a)
add_test_case(mqtt5_outbound_topic_alias_lru_a_b_c_a_cr_b)
add_test_case(mqtt5_outbound_topic_alias_lru_a_b_reset_a_b)

# mqtt operation/storage/view creation/relationship tests
add_test_case(mqtt5_publish_operation_new_set_no_optional)
add_test_case(mqtt5_publish_operation_new_set_all)
add_test_case(mqtt5_publish_operation_new_failure_packet_id)
add_test_case(mqtt5_subscribe_operation_new_set_no_optional)
add_test_case(mqtt5_subscribe_operation_new_set_all)
add_test_case(mqtt5_unsubscribe_operation_new_set_all)
add_test_case(mqtt5_connect_storage_new_set_no_optional)
add_test_case(mqtt5_connect_storage_new_set_all)
add_test_case(mqtt5_connack_storage_new_set_no_optional)
add_test_case(mqtt5_connack_storage_new_set_all)
add_test_case(mqtt5_disconnect_storage_new_set_no_optional)
add_test_case(mqtt5_disconnect_storage_new_set_all)
add_test_case(mqtt5_suback_storage_new_set_no_optional)
add_test_case(mqtt5_suback_storage_new_set_all)
add_test_case(mqtt5_unsuback_storage_new_set_no_optional)
add_test_case(mqtt5_unsuback_storage_new_set_all)
add_test_case(mqtt5_puback_storage_new_set_all)
add_test_case(mqtt5_publish_storage_new_set_all)

# operation/view validation failure tests
add_test_case(mqtt5_operation_disconnect_validation_failure_server_reference)
add_test_case(mqtt5_operation_disconnect_validation_failure_bad_reason_code)
add_test_case(mqtt5_operation_disconnect_validation_failure_reason_string_too_long)
add_test_case(mqtt5_operation_disconnect_validation_failure_reason_string_invalid_utf8)
add_test_case(mqtt5_operation_disconnect_validation_failure_user_properties_name_too_long)
add_test_case(mqtt5_operation_disconnect_validation_failure_user_properties_name_invalid_utf8)
add_test_case(mqtt5_operation_disconnect_validation_failure_user_properties_value_too_long)
add_test_case(mqtt5_operation_disconnect_validation_failure_user_properties_value_invalid_utf8)
add_test_case(mqtt5_operation_disconnect_validation_failure_user_properties_too_many)
add_test_case(mqtt5_operation_connect_validation_failure_client_id_too_long)
add_test_case(mqtt5_operation_connect_validation_failure_client_id_invalid_utf8)
add_test_case(mqtt5_operation_connect_validation_failure_username_too_long)
add_test_case(mqtt5_operation_connect_validation_failure_username_invalid_utf8)
add_test_case(mqtt5_operation_connect_validation_failure_password_too_long)
add_test_case(mqtt5_operation_connect_validation_failure_receive_maximum_zero)
add_test_case(mqtt5_operation_connect_validation_failure_maximum_packet_size_zero)
add_test_case(mqtt5_operation_connect_validation_failure_will_invalid)
add_test_case(mqtt5_operation_connect_validation_failure_will_payload_too_long)
add_test_case(mqtt5_operation_connect_validation_failure_auth_method_unsupported)
add_test_case(mqtt5_operation_connect_validation_failure_auth_data_unsupported)
add_test_case(mqtt5_operation_connect_validation_failure_request_problem_information_invalid)
add_test_case(mqtt5_operation_connect_validation_failure_request_response_information_invalid)
add_test_case(mqtt5_operation_connect_validation_failure_user_properties_name_too_long)
add_test_case(mqtt5_operation_connect_validation_failure_user_properties_name_invalid_utf8)
add_test_case(mqtt5_operation_connect_validation_failure_user_properties_value_too_long)
add_test_case(mqtt5_operation_connect_validation_failure_user_properties_value_invalid_utf8)
add_test_case(mqtt5_operation_connect_validation_failure_user_properties_too_many)
add_test_case(mqtt5_operation_subscribe_validation_failure_no_subscriptions)
add_test_case(mqtt5_operation_subscribe_validation_failure_too_many_subscriptions)
add_test_case(mqtt5_operation_subscribe_validation_failure_invalid_subscription_identifier)
add_test_case(mqtt5_operation_subscribe_validation_failure_invalid_topic_filter)
add_test_case(mqtt5_operation_subscribe_validation_failure_invalid_utf8_topic_filter)
add_test_case(mqtt5_operation_subscribe_validation_failure_invalid_qos)
add_test_case(mqtt5_operation_subscribe_validation_failure_invalid_retain_type)
add_test_case(mqtt5_operation_subscribe_validation_failure_invalid_no_local)
add_test_case(mqtt5_operation_subscribe_validation_failure_user_properties_name_too_long)
add_test_case(mqtt5_operation_subscribe_validation_failure_user_properties_name_invalid_utf8)
add_test_case(mqtt5_operation_subscribe_validation_failure_user_properties_value_too_long)
add_test_case(mqtt5_operation_subscribe_validation_failure_user_properties_value_invalid_utf8)
add_test_case(mqtt5_operation_subscribe_validation_failure_user_properties_too_many)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_no_topic_filters)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_too_many_topic_filters)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_invalid_topic_filter)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_invalid_utf8_topic_filter)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_user_properties_name_too_long)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_user_properties_name_invalid_utf8)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_user_properties_value_too_long)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_user_properties_value_invalid_utf8)
add_test_case(mqtt5_operation_unsubscribe_validation_failure_user_properties_too_many)
add_test_case(mqtt5_operation_publish_validation_failure_invalid_topic)
add_test_case(mqtt5_operation_publish_validation_failure_invalid_utf8_topic)
add_test_case(mqtt5_operation_publish_validation_failure_no_topic)
add_test_case(mqtt5_operation_publish_validation_failure_invalid_payload_format)
add_test_case(mqtt5_operation_publish_validation_failure_invalid_utf8_payload)
add_test_case(mqtt5_operation_publish_validation_failure_response_topic_too_long)
add_test_case(mqtt5_operation_publish_validation_failure_invalid_response_topic)
add_test_case(mqtt5_operation_publish_validation_failure_invalid_utf8_response_topic)
add_test_case(mqtt5_operation_publish_validation_failure_correlation_data_too_long)
add_test_case(mqtt5_operation_publish_validation_failure_content_type_too_long)
add_test_case(mqtt5_operation_publish_validation_failure_invalid_utf8_content_type)
add_test_case(mqtt5_operation_publish_validation_failure_subscription_identifier_exists)
add_test_case(mqtt5_operation_publish_validation_failure_topic_alias_zero)
add_test_case(mqtt5_operation_publish_validation_failure_user_properties_name_too_long)
add_test_case(mqtt5_operation_publish_validation_failure_user_properties_name_invalid_utf8)
add_test_case(mqtt5_operation_publish_validation_failure_user_properties_value_too_long)
add_test_case(mqtt5_operation_publish_validation_failure_user_properties_value_invalid_utf8)
add_test_case(mqtt5_operation_publish_validation_failure_user_properties_too_many)
add_test_case(mqtt5_operation_publish_validation_failure_qos0_duplicate_true)
add_test_case(mqtt5_operation_publish_validation_failure_qos0_with_packet_id)
add_test_case(mqtt5_client_options_validation_failure_no_host)
add_test_case(mqtt5_client_options_validation_failure_no_bootstrap)
add_test_case(mqtt5_client_options_validation_failure_no_publish_received)
add_test_case(mqtt5_client_options_validation_failure_invalid_socket_options)
add_test_case(mqtt5_client_options_validation_failure_invalid_connect)
add_test_case(mqtt5_client_options_validation_failure_invalid_keep_alive)
add_test_case(mqtt5_operation_subscribe_connection_settings_validation_failure_exceeds_maximum_packet_size)
add_test_case(mqtt5_operation_unsubscribe_connection_settings_validation_failure_exceeds_maximum_packet_size)
add_test_case(mqtt5_operation_publish_connection_settings_validation_failure_exceeds_maximum_packet_size)
add_test_case(mqtt5_operation_publish_connection_settings_validation_failure_exceeds_topic_alias_maximum)
add_test_case(mqtt5_operation_publish_connection_settings_validation_failure_exceeds_maximum_qos)
add_test_case(mqtt5_operation_publish_connection_settings_validation_failure_invalid_retain)
add_test_case(mqtt5_operation_disconnect_connection_settings_validation_failure_exceeds_maximum_packet_size)
add_test_case(mqtt5_operation_disconnect_connection_settings_validation_failure_promote_zero_session_expiry)

add_test_case(mqtt5_client_options_defaults_set)

add_test_case(mqtt5_operation_bind_packet_id_empty_table)
add_test_case(mqtt5_operation_bind_packet_id_multiple_with_existing)
add_test_case(mqtt5_operation_bind_packet_id_multiple_with_wrap_around)
add_test_case(mqtt5_operation_bind_packet_id_full_table)
add_test_case(mqtt5_operation_bind_packet_id_not_valid)
add_test_case(mqtt5_operation_bind_packet_id_already_bound)

add_test_case(mqtt5_operation_processing_nothing_empty_queue)
add_test_case(mqtt5_operation_processing_nothing_mqtt_connect)
add_test_case(mqtt5_operation_processing_nothing_clean_disconnect)
add_test_case(mqtt5_operation_processing_nothing_pending_write_completion_mqtt_connect)
add_test_case(mqtt5_operation_processing_nothing_pending_write_completion_connected)
add_test_case(mqtt5_operation_processing_nothing_pending_write_completion_clean_disconnect)
add_test_case(mqtt5_operation_processing_failure_message_allocation)
add_test_case(mqtt5_operation_processing_failure_message_send)
add_test_case(mqtt5_operation_processing_something_mqtt_connect)
add_test_case(mqtt5_operation_processing_something_clean_disconnect)
add_test_case(mqtt5_operation_processing_something_connected_multi)
add_test_case(mqtt5_operation_processing_something_connected_overflow)
add_test_case(mqtt5_operation_processing_disconnect_fail_all)
add_test_case(mqtt5_operation_processing_disconnect_fail_qos0)
add_test_case(mqtt5_operation_processing_disconnect_fail_non_qos1)
add_test_case(mqtt5_operation_processing_reconnect_rejoin_session_fail_all)
add_test_case(mqtt5_operation_processing_reconnect_rejoin_session_fail_qos0)
# intentionally skip the non_qos1 rejoin session case, there's no meaningful test given the logic
add_test_case(mqtt5_operation_processing_reconnect_no_session_fail_all)
add_test_case(mqtt5_operation_processing_reconnect_no_session_fail_qos0)
add_test_case(mqtt5_operation_processing_reconnect_no_session_fail_non_qos1)

add_test_case(mqtt5_negotiated_settings_reset_test)
add_test_case(mqtt5_negotiated_settings_apply_connack_test)
add_test_case(mqtt5_negotiated_settings_server_override_test)

# vli encode/decode
add_test_case(mqtt5_vli_size)
add_test_case(mqtt5_vli_success_round_trip)
add_test_case(mqtt5_vli_encode_failures)
add_test_case(mqtt5_vli_decode_failures)

# packet encode/decode cycle tests
add_test_case(mqtt5_packet_disconnect_round_trip)
add_test_case(mqtt5_packet_pingreq_round_trip)
add_test_case(mqtt5_packet_pingresp_round_trip)
add_test_case(mqtt5_packet_connect_round_trip)
add_test_case(mqtt5_packet_connack_round_trip)
add_test_case(mqtt5_packet_subscribe_round_trip)
add_test_case(mqtt5_packet_suback_round_trip)
add_test_case(mqtt5_packet_unsubscribe_round_trip)
add_test_case(mqtt5_packet_unsuback_round_trip)
add_test_case(mqtt5_packet_publish_round_trip)
add_test_case(mqtt5_packet_puback_round_trip)
add_test_case(mqtt5_packet_encode_connect_no_will)
add_test_case(mqtt5_packet_encode_connect_no_username)
add_test_case(mqtt5_packet_encode_connect_no_password)
add_test_case(mqtt5_packet_encode_connect_will_property_order)
add_test_case(mqtt5_first_byte_reserved_header_check_subscribe)
add_test_case(mqtt5_first_byte_reserved_header_check_unsubscribe)
add_test_case(mqtt5_first_byte_reserved_header_check_disconnect)

add_test_case(mqtt5_client_direct_connect_success)
add_test_case(mqtt5_client_direct_connect_sync_channel_failure)
add_test_case(mqtt5_client_direct_connect_async_channel_failure)
add_test_case(mqtt5_client_websocket_connect_sync_channel_failure)
add_test_case(mqtt5_client_websocket_connect_async_channel_failure)
add_test_case(mqtt5_client_websocket_connect_handshake_failure)
add_test_case(mqtt5_client_direct_connect_connack_refusal)
add_test_case(mqtt5_client_direct_connect_connack_timeout)
add_test_case(mqtt5_client_direct_connect_from_server_disconnect)
add_test_case(mqtt5_client_subscribe_success)
add_test_case(mqtt5_client_unsubscribe_success)
add_test_case(mqtt5_client_sub_pub_unsub_qos0)
add_test_case(mqtt5_client_sub_pub_unsub_qos1)
add_test_case(mqtt5_client_ping_sequence)
add_test_case(mqtt5_client_ping_timeout)
add_test_case(mqtt5_client_reconnect_failure_backoff)
add_test_case(mqtt5_client_reconnect_backoff_insufficient_reset)
add_test_case(mqtt5_client_reconnect_backoff_sufficient_reset)
add_test_case(mqtt5_client_subscribe_fail_packet_too_big)
add_test_case(mqtt5_client_disconnect_fail_packet_too_big)
add_test_case(mqtt5_client_flow_control_receive_maximum)
add_test_case(mqtt5_client_publish_timeout)
add_test_case(mqtt5_client_flow_control_iot_core_throughput)
add_test_case(mqtt5_client_flow_control_iot_core_publish_tps)
add_test_case(mqtt5_client_session_resumption_clean_start)
add_test_case(mqtt5_client_session_resumption_post_success)
add_test_case(mqtt5_client_session_resumption_always)
add_test_case(mqtt5_client_receive_qos1_return_puback_test)
add_test_case(mqtt5_client_receive_nonexisting_session_state)
add_test_case(mqtt5_client_receive_assigned_client_id)
add_test_case(mqtt5_client_no_session_after_client_stop)
add_test_case(mqtt5_client_restore_session_on_ping_timeout_reconnect)
add_test_case(mqtt5_client_discard_session_on_server_clean_start)
add_test_case(mqtt5_client_statistics_subscribe)
add_test_case(mqtt5_client_statistics_unsubscribe)
add_test_case(mqtt5_client_statistics_publish_qos0)
add_test_case(mqtt5_client_statistics_publish_qos1)
add_test_case(mqtt5_client_statistics_publish_qos1_requeue)
add_test_case(mqtt5_client_puback_ordering)
add_test_case(mqtt5_client_listeners)
add_test_case(mqtt5_client_offline_operation_submission_fail_all)
add_test_case(mqtt5_client_offline_operation_submission_fail_qos0)
add_test_case(mqtt5_client_offline_operation_submission_fail_non_qos1)
add_test_case(mqtt5_client_offline_operation_submission_then_connect)
add_test_case(mqtt5_client_inbound_alias_success)
add_test_case(mqtt5_client_inbound_alias_failure_disabled)
add_test_case(mqtt5_client_inbound_alias_failure_zero_id)
add_test_case(mqtt5_client_inbound_alias_failure_too_large_id)
add_test_case(mqtt5_client_inbound_alias_failure_unbound_id)
add_test_case(mqtt5_client_outbound_alias_disabled_failure_alias_set)
add_test_case(mqtt5_client_outbound_alias_user_failure_empty_topic)
add_test_case(mqtt5_client_outbound_alias_lru_failure_alias_set)

# a, b, c, r imply notation as the outbound resolver unit tests above
add_test_case(mqtt5_client_outbound_alias_user_success_a_b_ar_br)
add_test_case(mqtt5_client_outbound_alias_lru_success_a_b_c_br_cr_a)

add_test_case(rate_limiter_token_bucket_init_invalid)
add_test_case(rate_limiter_token_bucket_regeneration_integral)
add_test_case(rate_limiter_token_bucket_regeneration_fractional)
add_test_case(rate_limiter_token_bucket_fractional_iteration)
add_test_case(rate_limiter_token_bucket_large_fractional_iteration)
add_test_case(rate_limiter_token_bucket_real_iteration)
add_test_case(rate_limiter_token_bucket_reset)

# mqtt5 to 3 adapter tests

add_test_case(mqtt5to3_adapter_create_destroy)
add_test_case(mqtt5to3_adapter_create_destroy_delayed)
add_test_case(mqtt5to3_adapter_set_will)
add_test_case(mqtt5to3_adapter_set_login)
add_test_case(mqtt5to3_adapter_set_reconnect_timeout)
add_test_case(mqtt5to3_adapter_connect_success)
add_test_case(mqtt5to3_adapter_connect_success_disconnect_success)
add_test_case(mqtt5to3_adapter_connect_success_disconnect_success_thrice)
add_test_case(mqtt5to3_adapter_connect_success_connect_failure)
add_test_case(mqtt5to3_adapter_connect_success_sloppy_shutdown)
add_test_case(mqtt5to3_adapter_connect_bad_connectivity)
add_test_case(mqtt5to3_adapter_connect_bad_connectivity_with_mqtt5_restart)
add_test_case(mqtt5to3_adapter_connect_failure_connect_success_via_mqtt5)
add_test_case(mqtt5to3_adapter_connect_failure_bad_config_success_good_config)
add_test_case(mqtt5to3_adapter_connect_reconnect_failures)
add_test_case(mqtt5to3_adapter_connect_success_disconnect_connect)
add_test_case(mqtt5to3_adapter_connect_success_stop_mqtt5_disconnect_success)
add_test_case(mqtt5to3_adapter_disconnect_success)
add_test_case(mqtt5to3_adapter_connect_success_disconnect_success_disconnect_success)
add_test_case(mqtt5to3_adapter_operation_allocation_simple)
add_test_case(mqtt5to3_adapter_operation_allocation_wraparound)
add_test_case(mqtt5to3_adapter_operation_allocation_exhaustion)
add_test_case(mqtt5to3_adapter_publish_failure_invalid)
add_test_case(mqtt5to3_adapter_publish_failure_offline_queue_policy)
add_test_case(mqtt5to3_adapter_publish_success_qos0)
add_test_case(mqtt5to3_adapter_publish_success_qos1)
add_test_case(mqtt5to3_adapter_publish_no_ack)
add_test_case(mqtt5to3_adapter_publish_interrupted)
add_test_case(mqtt5to3_adapter_subscribe_single_success)
add_test_case(mqtt5to3_adapter_subscribe_multi_success)
add_test_case(mqtt5to3_adapter_subscribe_single_failure)
add_test_case(mqtt5to3_adapter_subscribe_single_invalid)
add_test_case(mqtt5to3_adapter_subscribe_multi_failure)
add_test_case(mqtt5to3_adapter_subscribe_multi_invalid)
add_test_case(mqtt5to3_adapter_subscribe_single_publish)
add_test_case(mqtt5to3_adapter_subscribe_multi_overlapping_publish)
add_test_case(mqtt5to3_adapter_unsubscribe_success)
add_test_case(mqtt5to3_adapter_unsubscribe_failure)
add_test_case(mqtt5to3_adapter_unsubscribe_invalid)
add_test_case(mqtt5to3_adapter_unsubscribe_overlapped)
add_test_case(mqtt5to3_adapter_get_stats)
add_test_case(mqtt5to3_adapter_resubscribe_nothing)
add_test_case(mqtt5to3_adapter_resubscribe_something)
add_test_case(mqtt5to3_adapter_subscribe_single_null_suback)
add_test_case(mqtt5to3_adapter_subscribe_multi_null_suback)
add_test_case(mqtt5to3_adapter_operation_callbacks_after_shutdown)

add_test_case(mqtt_subscription_set_add_empty_not_subbed)
add_test_case(mqtt_subscription_set_add_single_path)
add_test_case(mqtt_subscription_set_add_overlapped_branching_paths)
add_test_case(mqtt_subscription_set_remove_overlapping_path)
add_test_case(mqtt_subscription_set_remove_branching_path)
add_test_case(mqtt_subscription_set_remove_invalid)
add_test_case(mqtt_subscription_set_remove_empty_segments)
add_test_case(mqtt_subscription_set_add_remove_repeated)
add_test_case(mqtt_subscription_set_publish_single_path)
add_test_case(mqtt_subscription_set_publish_multi_path)
add_test_case(mqtt_subscription_set_publish_single_level_wildcards)
add_test_case(mqtt_subscription_set_publish_multi_level_wildcards)
add_test_case(mqtt_subscription_set_get_subscriptions)

generate_test_driver(${PROJECT_NAME}-tests)

set(TEST_PAHO_CLIENT_BINARY_NAME ${PROJECT_NAME}-paho-client)

add_executable(${TEST_PAHO_CLIENT_BINARY_NAME} "v3-client/paho_client_test.c")
target_link_libraries(${TEST_PAHO_CLIENT_BINARY_NAME} PRIVATE ${PROJECT_NAME})
aws_set_common_properties(${TEST_PAHO_CLIENT_BINARY_NAME})
aws_add_sanitizers(${TEST_PAHO_CLIENT_BINARY_NAME} ${${PROJECT_NAME}_SANITIZERS})
target_compile_definitions(${TEST_PAHO_CLIENT_BINARY_NAME} PRIVATE AWS_UNSTABLE_TESTING_API=1)
target_include_directories(${TEST_PAHO_CLIENT_BINARY_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR})

set(TEST_IOT_CLIENT_BINARY_NAME ${PROJECT_NAME}-iot-client)

add_executable(${TEST_IOT_CLIENT_BINARY_NAME} "v3-client/aws_iot_client_test.c")
target_link_libraries(${TEST_IOT_CLIENT_BINARY_NAME} PRIVATE ${PROJECT_NAME})
aws_set_common_properties(${TEST_IOT_CLIENT_BINARY_NAME})
aws_add_sanitizers(${TEST_IOT_CLIENT_BINARY_NAME} ${${PROJECT_NAME}_SANITIZERS})
target_compile_definitions(${TEST_IOT_CLIENT_BINARY_NAME} PRIVATE AWS_UNSTABLE_TESTING_API=1)
target_include_directories(${TEST_IOT_CLIENT_BINARY_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
