#include <GPSUBlox.hpp>
#include <CppUTest/CommandLineTestRunner.h>
#include "CppUTest/TestHarness.h"
#include "CppUTestExt/MockSupport.h"
#include <iostream>

// #include <DevicePowerSwitchSpy.hpp>
#include <MockUART.hpp>

TEST_GROUP(UBloxTestGroup)
{
	MockUART* uart_mock = nullptr;
	UART* uart = nullptr;

	GPSUBlox* gps = nullptr;

	// Contents of this valid msg is taken from pg 38 of UBlox manual:
	// https://content.u-blox.com/sites/default/files/u-blox-M9-SPG-4.04_InterfaceDescription_UBX-21022436.pdf
	const char* valid_pubx00_msg = "$PUBX,00,081350.00,4717.113210,N,00833.915187,E,546.589,G3,2.1,"
								   "2.0,0.007,77.52,0.007,,0.92,1.19,0.77,9,0,0*5F\r\n";
	const uint8_t valid_pubx00_msg_crc = uint8_t(0x5F);

	void setup()
	{
		uart_mock = new MockUART;
		uart = reinterpret_cast<UART*>(uart_mock);

		gps = new GPSUBlox(*uart);
	}

	void teardown()
	{
		mock().checkExpectations();
		mock().removeAllComparatorsAndCopiers();
		mock().clear();

		delete uart_mock;
		delete gps;
	}
};

TEST(UBloxTestGroup, parsePUBX00)
{
	// TODO: needs fixed
#if 0
	GPS::GPSFix fix = {};
	memcpy(fix.msg, valid_pubx00_msg, strlen(valid_pubx00_msg));

	std::ignore = gps->parsePUBX00(fix);

	LONGS_EQUAL(8, fix.TOF.hour);
#endif
}
