Repository: TheAlgorithms/C-Plus-Plus
File: dynamic_programming/Unbounded_0_1_Knapsack.cpp (C++)

Code before:
    std::cout << "Maximum Knapsack value " << unboundedKnapsack(N1, W1, val1, wt1) << std::endl;

    // Test Case 2
    std::uint16_t N2 = 3; // Number of items
    std::vector<std::uint16_t> wt2 = {10, 20, 30}; // Weights of the items
    std::vector<std::uint16_t> val2 = {60, 100, 120}; // Values of the items
    std::uint16_t W2 = 5; // Maximum capacity of the knapsack
    // Test the function and assert the expected output
    assert(unboundedKnapsack(N2, W2, val2, wt2) == 0);
    std::cout << "Maximum Knapsack value " << unboundedKnapsack(N2, W2, val2, wt2) << std::endl;

    // Test Case 3
    std::uint16_t N3 = 3; // Number of items
    std::vector<std::uint16_t> wt3 = {2, 4, 6}; // Weights of the items
    std::vector<std::uint16_t> val3 = {5, 11, 13};// Values of the items 
    std::uint16_t W3 = 27;// Maximum capacity of the knapsack 
    // Test the function and assert the expected output
    assert(unboundedKnapsack(N3, W3, val3, wt3) == 27);
    std::cout << "Maximum Knapsack value " << unboundedKnapsack(N3, W3, val3, wt3) << std::endl;
  
    std::cout << "All test cases passed!" << std::endl;

}

int main() {
    tests(); // Run test cases to validate implementation
    return 0;
}

}
}


Review comment (suggestion):
```suggestion
    tests(); // Run self test implementation 
```


Code after:
    std::vector<std::uint16_t> wt1 = {1, 3, 4, 5}; // Weights of the items
    std::vector<std::uint16_t> val1 = {6, 1, 7, 7}; // Values of the items
    std::uint16_t W1 = 8; // Maximum capacity of the knapsack
    // Test the function and assert the expected output
    assert(unboundedKnapsack(N1, W1, val1, wt1) == 48);
    std::cout << "Maximum Knapsack value " << unboundedKnapsack(N1, W1, val1, wt1) << std::endl;

    // Test Case 2
    std::uint16_t N2 = 3; // Number of items
    std::vector<std::uint16_t> wt2 = {10, 20, 30}; // Weights of the items
    std::vector<std::uint16_t> val2 = {60, 100, 120}; // Values of the items
    std::uint16_t W2 = 5; // Maximum capacity of the knapsack
    // Test the function and assert the expected output
    assert(unboundedKnapsack(N2, W2, val2, wt2) == 0);
    std::cout << "Maximum Knapsack value " << unboundedKnapsack(N2, W2, val2, wt2) << std::endl;

    // Test Case 3
    std::uint16_t N3 = 3; // Number of items
    std::vector<std::uint16_t> wt3 = {2, 4, 6}; // Weights of the items
    std::vector<std::uint16_t> val3 = {5, 11, 13};// Values of the items 
    std::uint16_t W3 = 27;// Maximum capacity of the knapsack 
    // Test the function and assert the expected output
    assert(unboundedKnapsack(N3, W3, val3, wt3) == 27);
    std::cout << "Maximum Knapsack value " << unboundedKnapsack(N3, W3, val3, wt3) << std::endl;

    // Test Case 4
    std::uint16_t N4 = 0; // Number of items
    std::vector<std::uint16_t> wt4 = {}; // Weights of the items
    std::vector<std::uint16_t> val4 = {}; // Values of the items 
    std::uint16_t W4 = 10; // Maximum capacity of the knapsack
    assert(unboundedKnapsack(N4, W4, val4, wt4) == 0); 
    std::cout << "Maximum Knapsack value for empty arrays: " << unboundedKnapsack(N4, W4, val4, wt4) << std::endl;
  
    std::cout << "All test cases passed!" << std::endl;

}

/**
 * @brief main function
 * @return 0 on successful exit
 */
int main() {
    tests(); // Run self test implementation 
    return 0;
}