Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create unit tests for fullness #42

Merged
merged 4 commits into from
May 19, 2022

Conversation

aahsue
Copy link
Contributor

@aahsue aahsue commented May 12, 2022

Description

Created unit tests using the Mock Distance Sensor and the Fullness Class. Checked if mock distance sensor can be constructed, that it returns the correct distance, that it can loop through the distances, and that the Fullness class returns the correct fullness and if it can recognize if a distance is valid.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code improvement (a non-breaking change that improves the quality of the code)
  • Documentation Change (update to the documentation with no changes to the code)

Testing and Verification Instructions

  1. Build and compile and there are no errors
  2. Run the unit tests and they all pass

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

aahsue and others added 3 commits May 12, 2022 14:08
… are not implemented in this branch. this is based off of them theoretically being in our codebase.

Co-authored-by: Lily Johnson <41386414+lilyjohnson@users.noreply.github.com>
… class

Co-authored-by: Lily Johnson <41386414+lilyjohnson@users.noreply.github.com>
@aahsue aahsue linked an issue May 12, 2022 that may be closed by this pull request
Copy link
Contributor

@patrickanguyen patrickanguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More meaningful tests needed to be added in the future, but we can just merge this once these changes are made

Comment on lines 6 to 9
void test_can_construct_mock_distance_sensor()
{
Fullness::MockDistance mockDistanceSensor({3, -6, 27, 114, 9});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

void test_returns_correct_fullness()
{
uint32_t binHeight = 10;
int32_t calculatedAverageDistance = 5; // should be 5.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a float

Fullness::MockDistance mockDistanceSensor(distances);

Fullness::FullnessMetric mockFullness(binHeight, mockDistanceSensor);
TEST_ASSERT_EQUAL_INT(calculatedAverageDistance, (mockFullness.getFullness()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getFullness() returns a float

Comment on lines 42 to 43
uint32_t binHeight = 10;
int32_t calculatedAverageDistance = 5; // should be 5.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these const

@limenilbuz
Copy link
Contributor

lgtm

Copy link

@sagarbpatel31 sagarbpatel31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm now

@patrickanguyen patrickanguyen merged commit 02efe80 into main May 19, 2022
@patrickanguyen patrickanguyen deleted the 24-create-unit-tests-for-fullness branch May 19, 2022 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create unit tests for Fullness
4 participants