Part A : Implement a function called min which takes a tuple of two numeric values and returns the lower value of the two. Implementation notes: • If needed, use Erlang function guards • Do NOT use the if or case structures Sample calls: > exam:min({3, 4}). 3 > exam:min({4, 3}). 3 Part B: Implement at least three unique unit tests to test the min function created in Part A. Each test must test a different aspect of the min function. Implementation notes: • An import for the Erlang Unit Test library is included in exam.erl • Use the Erlang Unit Test library to write the unit tests • Write each unit test in its own function Upload • Include the unit test functions in exam.erl exam.erl file -module(exam). -compile(export_all). -include_lib("eunit/include/eunit.hrl").
Part A :
Implement a function called min which takes a tuple of two numeric values and returns the lower value of the two.
Implementation notes:
• If needed, use Erlang function guards
• Do NOT use the if or case structures
Sample calls:
> exam:min({3, 4}).
3
> exam:min({4, 3}).
3
Part B:
Implement at least three unique unit tests to test the min function created in Part A. Each test
must test a different aspect of the min function.
Implementation notes:
• An import for the Erlang Unit Test library is included in exam.erl
• Use the Erlang Unit Test library to write the unit tests
• Write each unit test in its own function
Upload
• Include the unit test functions in exam.erl
exam.erl file
-module(exam).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
Trending now
This is a popular solution!
Step by step
Solved in 2 steps