<commit_before>///
/// @file
/// @details Defines the functions that perform the basic tests for the racecar drivetrain.
///
/// <!-- Copyright (c) <NAME> 2017 - All Rights Reserved -->
///-----------------------------------------------------------------------------------------------------------------///

#include "basic_test.h"

#include "../racecar/racecar_wheel.h"

#include <cstdio>

#define log_test(message, ...)   printf(message, ##__VA_ARGS__)
static const float kTestElipson(0.0001f);

class RotatingMass : public Racecar::RotatingBody
{
public:
	explicit RotatingMass(const float momentOfInertia) :
		RotatingBody()
	{
		SetInertia(momentOfInertia);
	}

	RotatingMass(const float massInKilograms, const float radiusInMeters) :
		RotatingBody()
	{
		SetInertia(Racecar::ComputeInertiaMetric(massInKilograms, radiusInMeters));
	}

	virtual ~RotatingMass(void)
	{
	}
};

bool Racecar::UnitTests::PerformBasicTests(void)
{
	RotatingMass rotatingMass(10.0f); //10kg-m.
	RotatingMass rotatingMass2(10.0f, 1.0f);

	if (fabsf(rotatingMass.GetInertia() - rotatingMass2.GetInertia() > kTestElipson))
	{
		log_test("Failed accessing expected moments of inertia.");
		return false;
	}

	return false;
}<commit_msg>Adding more tests!<commit_after>///
/// @file
/// @details Defines the functions that perform the basic tests for the racecar drivetrain.
///
/// <!-- Copyright (c) <NAME> 2017 - All Rights Reserved -->
///-----------------------------------------------------------------------------------------------------------------///

#include "basic_test.h"

#include "../racecar/racecar_wheel.h"

#include <cstdio>

#define log_test(message, ...)   printf(message, ##__VA_ARGS__)
static const float kTestElipson(0.0001f);

class RotatingMass : public Racecar::RotatingBody
{
public:
	explicit RotatingMass(const float momentOfInertia) :
		RotatingBody()
	{
		SetInertia(momentOfInertia);
	}

	RotatingMass(const float massInKilograms, const float radiusInMeters) :
		RotatingBody()
	{
		SetInertia(Racecar::ComputeInertiaMetric(massInKilograms, radiusInMeters));
	}

	virtual ~RotatingMass(void)
	{
	}
};

bool ConstructionTest(void);
bool ConstantTorqueTest(void);

bool Racecar::UnitTests::PerformBasicTests(void)
{
	if (false == ConstructionTest()) { log_test("Failed: Expected to pass the ConstructionTest().\n"); return false; }
	if (false == ConstantTorqueTest()) { log_test("Failed: Expected to pass the ConstantTorqueTest().\n"); return false; }

	log_test("The Racecar has successfully passed technical inspection. You may now go racing!");
	return true;
}


bool ConstructionTest(void)
{
	RotatingMass rotatingMass(10.0f); //10kg-m.
	if (fabsf(rotatingMass.GetInertia() - 10.0f) > kTestElipson)
	{
		log_test("Failed accessing expected moments of inertia.");
		return false;
	}

	RotatingMass rotatingMass2(10.0f, 1.0f);
	if (fabsf(rotatingMass.GetInertia() - rotatingMass2.GetInertia()) > kTestElipson)
	{
		log_test("Failed accessing expected moments of inertia.");
		return false;
	}

	const float startingVelocity(rotatingMass.GetAngularVelocity());
	if (fabsf(startingVelocity) > kTestElipson)
	{
		log_test("Failed: Expected rotating body to have no angular velocity upon construction. Found: %f\n", startingVelocity);
		return false;
	}

	return true;
}

bool ConstantTorqueTest(void)
{
	RotatingMass rotatingMass(10.0f); //10kg-m.

	//Simulate 1 second of applying a 10Nm torque to the rotating body.
	for (int timer(0); timer < 1000; timer += 10)
	{
		rotatingMass.ApplyDownstreamTorque(10.0f, rotatingMass);
		rotatingMass.Simulate(); //Simulates 10ms of action.
	}

	const float finalVelocity(rotatingMass.GetAngularVelocity());
	log_test("Final velocity: %f\n", finalVelocity);
	
	return false;
}
{'fraction_non_alphanumeric': 0.18426000537201181, 'fraction_numerical': 0.0174590384098845, 'mean_word_length': 3.547008547008547, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6252131', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1189, 'n_words': 278}