What is Nostr?
techfeudalist /
npub1nz3…yxqu
2023-08-10 19:06:37
in reply to nevent1q…ptmn

techfeudalist on Nostr: Here’s a super simple example: To AI: Imagine a function that takes two integers ...

Here’s a super simple example:

To AI:

Imagine a function that takes two integers and adds them returns true if the sum is less than 100, else false, propose three tests

——-

AI might respond…

Sure, here are three test cases for such a function:

1. **Test Case 1: Two small numbers**
- Input: 5, 10
- Expected Output: True (because 5 + 10 = 15, which is less than 100)

2. **Test Case 2: Numbers summing up to exactly 100**
- Input: 60, 40
- Expected Output: False (because 60 + 40 = 100, which is not less than 100)

3. **Test Case 3: Large numbers exceeding 100**
- Input: 75, 50
- Expected Output: False (because 75 + 50 = 125, which is more than 100)

You'd want a range of test cases to ensure that the function behaves correctly for different kinds of inputs.

———

Now write the JS function and tests using Jest

—————

Certainly! Here's how you would write the first test for the function using Jest:

First, let's define the function (I'll name it `isSumLessThan100`):

```javascript
function isSumLessThan100(a, b) {
return a + b < 100;
}
```

Now, let's write a Jest test for it:

```javascript
const isSumLessThan100 = require('./path-to-your-function-file'); // Import the function

describe('isSumLessThan100', () => {
test('should return true for numbers summing to less than 100', () => {
const result = isSumLessThan100(5, 10);
expect(result).toBe(true);
});
});
```
Author Public Key
npub1nz3cd3mx4jf9paxwrdgqvchaprjdge9pj9t58mkusw74q5saajkqu0yxqu