1. 31
    Rustlings test3: Testing a function multiple times
    39s

Rustlings test3: Testing a function multiple times

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

Chris Biscardi: [0:00] Exercises test3 is a test for the Tests section that we just went through. Currently, the comment in this file tells us that the test isn't testing our function, make it do so in such a way that the test passes. Then, we have to write a second test that tests what happens when we call our function "times_two" with a negative number.

[0:16] Again, we have our public function "times_two" that takes a number and returns a number. The body of the function implicitly returns number times two, and then we configure our test module. In this case, returns_twice_of_positive_numbers uses the assert_equal! Macro, to test times_two on four, which is eight.

[0:33] Now we have to do the same thing for negative four, which will be negative eight. We can test to make sure that our test is running by making it fail.

egghead
egghead
~ 26 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today