From c18a994e73161ffa06ee44136dc88f49c2169add Mon Sep 17 00:00:00 2001
From: "St. Elmo" <stelmozors@gmail.com>
Date: Fri, 9 Jul 2021 13:22:27 +0200
Subject: [PATCH] added more tests

---
 test/reconstruction/CoreModel.jl     | 16 +++++++++++++---
 test/reconstruction/StandardModel.jl | 28 ++++++++++++++++++++++------
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/test/reconstruction/CoreModel.jl b/test/reconstruction/CoreModel.jl
index 0f837a8b2..9d8bcab5a 100644
--- a/test/reconstruction/CoreModel.jl
+++ b/test/reconstruction/CoreModel.jl
@@ -12,9 +12,14 @@ using Base: lowerbound, upperbound
     change_bound!(cp, "r1", lower_bound=-101, upper_bound=101)
     @test cp.xl[1] == -101
     @test cp.xu[1] == 101
-    change_bounds!(cp, ["r1","r2"]; lower_bounds=[-113, -12.23], upper_bounds=[113, 233.0])
+    change_bounds!(cp, ["r1","r2"]; lower_bounds=[-113, -12.23], upper_bounds=[114, 233.0])
     @test cp.xl[2] == -12.23
-    @test cp.xu[1] == 113
+    @test cp.xu[1] == 114
+    change_bounds!(cp, ["r1","r2"]; lower_bounds=[-114, nothing], upper_bounds=[nothing, 2333.0])
+    @test cp.xl[1] == -114
+    @test cp.xl[2] == -12.23
+    @test cp.xu[1] == 114
+    @test cp.xu[2] == 2333
 
     new_model = change_bound(cp, 1, lower_bound=-10, upper_bound=10)
     @test new_model.xl[1] == -10
@@ -26,9 +31,14 @@ using Base: lowerbound, upperbound
     new_model = change_bound(cp, "r1", lower_bound=-101, upper_bound=101)
     @test new_model.xl[1] == -101
     @test new_model.xu[1] == 101
-    new_model = change_bounds(cp, ["r1","r2"]; lower_bounds=[-113, -12.23], upper_bounds=[113, 233.0])
+    new_model = change_bounds(cp, ["r1","r2"]; lower_bounds=[-113, -12.23], upper_bounds=[113, 1000])
     @test new_model.xl[2] == -12.23
     @test new_model.xu[1] == 113
+    new_model = change_bounds(cp, ["r1", "r2"]; lower_bounds=[nothing, -10], upper_bounds=[110, nothing])
+    @test new_model.xl[1] == -114
+    @test new_model.xl[2] == -10
+    @test new_model.xu[1] == 110
+    @test new_model.xu[2] == 2333
 end
 
 @testset "Verify consistency" begin
diff --git a/test/reconstruction/StandardModel.jl b/test/reconstruction/StandardModel.jl
index 7a38cb731..8ae3b7098 100644
--- a/test/reconstruction/StandardModel.jl
+++ b/test/reconstruction/StandardModel.jl
@@ -36,24 +36,40 @@
     change_bound!(model, "r2"; lower_bound=-10, upper_bound=10)
     @test model.reactions["r2"].lb == -10
     @test model.reactions["r2"].ub == 10
-    
-    change_bounds!(model, ["r1", "r2"]; lower_bounds=[-10, -20], upper_bounds=[10.0, 20.0])
-    @test model.reactions["r1"].lb == -10
-    @test model.reactions["r1"].ub == 10
-    @test model.reactions["r2"].lb == -20
-    @test model.reactions["r2"].ub == 20
+    change_bound!(model, "r2"; lower_bound=-100)
+    @test model.reactions["r2"].lb == -100
+    @test model.reactions["r2"].ub == 10
+    change_bound!(model, "r2"; upper_bound=111)
+    @test model.reactions["r2"].lb == -100
+    @test model.reactions["r2"].ub == 111
+
+    change_bounds!(model, ["r1", "r2"]; lower_bounds=[-110, -220], upper_bounds=[110.0, 220.0])
+    @test model.reactions["r1"].lb == -110
+    @test model.reactions["r1"].ub == 110
+    @test model.reactions["r2"].lb == -220
+    @test model.reactions["r2"].ub == 220
     
     # change bound - new model
     new_model = change_bound(model, "r2"; lower_bound=-10, upper_bound=10)
     @test new_model.reactions["r2"].lb == -10
     @test new_model.reactions["r2"].ub == 10
     
+    new_model = change_bound(model, "r2"; lower_bound=-10)
+    @test new_model.reactions["r2"].lb == -10
+    @test new_model.reactions["r2"].ub == 220
+    
     new_model = change_bounds(model, ["r1", "r2"]; lower_bounds=[-10, -20], upper_bounds=[10.0, 20.0])
     @test new_model.reactions["r1"].lb == -10
     @test new_model.reactions["r1"].ub == 10
     @test new_model.reactions["r2"].lb == -20
     @test new_model.reactions["r2"].ub == 20
 
+    new_model = change_bounds(model, ["r1", "r2"]; lower_bounds=[-10, nothing], upper_bounds=[nothing, 20.0])
+    @test new_model.reactions["r1"].lb == -10
+    @test new_model.reactions["r1"].ub == 110
+    @test new_model.reactions["r2"].lb == -220
+    @test new_model.reactions["r2"].ub == 20
+
     ### reactions
     add_reactions!(model, [r3, r4])
     @test length(model.reactions) == 4
-- 
GitLab