Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
247386a
Adding product line based population in the dictionary as the Annotat…
igajurelNCQA Sep 3, 2025
2b4b555
FIxed bug - when date is assigned as Maz/Min value, Quantity add/subt…
igajurelNCQA Sep 4, 2025
73a0e74
Fix Bug - Slice operation fixed to follow Slice semantics used by htt…
igajurelNCQA Sep 4, 2025
9783b97
unit tests for Slice fixes
igajurelNCQA Sep 5, 2025
282d5a6
Fixed Units normalization - A datetime quantity unit can be ucum or c…
igajurelNCQA Sep 5, 2025
35e6535
just retain unit normalization based changes
igajurelNCQA Sep 10, 2025
ef21f0e
Merge branch 'develop' into Unit-normalization-fixes-for-UCUM-and-Cal…
igajurelNCQA Sep 10, 2025
4aab83d
xml fix
igajurelNCQA Sep 13, 2025
344b344
Merge branch 'develop' into Unit-normalization-fixes-for-UCUM-and-Cal…
igajurelNCQA Sep 13, 2025
d6466ae
Merge branch 'develop' into Unit-normalization-fixes-for-UCUM-and-Cal…
igajurelNCQA Sep 17, 2025
24cd09d
resolve issues with public API shipped constructs
igajurelNCQA Sep 17, 2025
d1c3a15
Merge branch 'develop' into Unit-normalization-fixes-for-UCUM-and-Cal…
igajurelNCQA Sep 18, 2025
915f64d
Merge branch 'develop' into Unit-normalization-fixes-for-UCUM-and-Cal…
igajurelNCQA Sep 19, 2025
651e655
address copilot comments
igajurelNCQA Sep 19, 2025
55a203e
Update Cql/Cql.Abstractions/Abstractions/UCUMUnits.cs
igajurelNCQA Sep 19, 2025
7a8bdc1
address copilot comment
igajurelNCQA Sep 19, 2025
6c9d8ff
Merge branch 'Unit-normalization-fixes-for-UCUM-and-Calendar-based-Cq…
igajurelNCQA Sep 19, 2025
ea583bc
address copilot comment
igajurelNCQA Sep 19, 2025
366d2c0
Improve readability with cql temporal types by using switch expressions
baseTwo Sep 22, 2025
63a3f19
Uncomment cql to elm step to allow ELM files to be deleted when Clean…
baseTwo Sep 22, 2025
90ae302
Refactor ToDateTimePrecision and update copyright
baseTwo Sep 22, 2025
4254920
Refactor tests and simplify parsing logic
baseTwo Sep 22, 2025
518fbc6
Refactor date/time arithmetic and add operator support
baseTwo Sep 22, 2025
46d429a
Refactor PrimitiveTests and split test classes
baseTwo Sep 22, 2025
f9266ec
Update submodules with uncommitted local changes
baseTwo Sep 22, 2025
59b6abb
Enable nullable annotations and add CqlQuantity tests
baseTwo Sep 22, 2025
b4baab4
Standardize unit strings in LiteralTest.cs
baseTwo Sep 22, 2025
2b352f5
Add comment and return unit text in TerminalParsers.cs
baseTwo Sep 23, 2025
f5faeb3
Disable CqlToElm
baseTwo Sep 23, 2025
b282ba0
submodules
baseTwo Sep 23, 2025
0d74d39
Refactor UCUM unit handling and improve maintainability
baseTwo Sep 23, 2025
2ba2f63
submodule
baseTwo Sep 23, 2025
125f413
Fix assertion
baseTwo Sep 23, 2025
accfe28
UCUM units not supported on difference between dates https://cql.hl7.…
baseTwo Sep 23, 2025
ebb815e
submodule
baseTwo Sep 23, 2025
07669c5
submodule
baseTwo Sep 23, 2025
a288a12
Split up classes in their own files
baseTwo Sep 23, 2025
6beff41
Additional tests
baseTwo Sep 23, 2025
4ab1d7d
Move a datetime test from the date to datetime tests
baseTwo Sep 24, 2025
79b7392
submodule
baseTwo Sep 28, 2025
c31459c
Merge branch 'develop' into 1024-fix-unit-normalization-for-quantity-…
baseTwo Sep 28, 2025
6ca7360
submodule
baseTwo Sep 28, 2025
dac543c
Merge branch '1024-fix-unit-normalization-for-quantity-units-such-as-…
baseTwo Sep 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions Cql/CoreTests/CqlDateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright (c) 2025, Firely, NCQA and contributors
* See the file CONTRIBUTORS for details.
*
* This file is licensed under the BSD 3-Clause license
* available at https://raw.githubusercontent.com/FirelyTeam/firely-cql-sdk/main/LICENSE
*/

#nullable enable
using Hl7.Cql.Iso8601;
using Hl7.Cql.Primitives;

namespace CoreTests;

[TestClass]
[TestCategory("UnitTest")]
public class CqlDateTests
{
[TestMethod]
public void Add_Years()
{
var date = new CqlDate(2020, 1, 1);
var quantity = new CqlQuantity(2, "year");
var result = date.Add(quantity);
Assert.AreEqual(new CqlDate(2022, 1, 1), result);
}

[TestMethod]
public void Add_Months()
{
var date = new CqlDate(2020, 1, 31);
var quantity = new CqlQuantity(1, "month");
var result = date.Add(quantity);
Assert.AreEqual(new CqlDate(2020, 2, 29), result); // Leap year
}

[TestMethod]
public void Add_Days()
{
var date = new CqlDate(2020, 2, 27);
var quantity = new CqlQuantity(2, "day");
var result = date.Add(quantity);
Assert.AreEqual(new CqlDate(2020, 2, 29), result);
}

[TestMethod]
public void Subtract_Years()
{
var date = new CqlDate(2020, 1, 1);
var quantity = new CqlQuantity(5, "year");
var result = date.Subtract(quantity);
Assert.AreEqual(new CqlDate(2015, 1, 1), result);
}

[TestMethod]
public void Subtract_Months()
{
var date = new CqlDate(2020, 3, 31);
var quantity = new CqlQuantity(1, "month");
var result = date.Subtract(quantity);
Assert.AreEqual(new CqlDate(2020, 2, 29), result); // Leap year
}

[TestMethod]
public void Subtract_Days()
{
var date = new CqlDate(2020, 3, 1);
var quantity = new CqlQuantity(1, "day");
var result = date.Subtract(quantity);
Assert.AreEqual(new CqlDate(2020, 2, 29), result);
}

[TestMethod]
public void Operator_Addition()
{
var date = new CqlDate(2021, 12, 31);
var quantity = new CqlQuantity(1, "day");
var result = date + quantity;
Assert.AreEqual(new CqlDate(2022, 1, 1), result);
}

[TestMethod]
public void Operator_Subtraction()
{
var date = new CqlDate(2022, 1, 1);
var quantity = new CqlQuantity(1, "day");
var result = date - quantity;
Assert.AreEqual(new CqlDate(2021, 12, 31), result);
}

[TestMethod]
public void Add_NullQuantity_ReturnsNull()
{
var date = new CqlDate(2020, 1, 1);
CqlQuantity? quantity = null;
var result = date.Add(quantity);
Assert.IsNull(result);
}

[TestMethod]
public void Subtract_NullQuantity_ReturnsNull()
{
var date = new CqlDate(2020, 1, 1);
CqlQuantity? quantity = null;
var result = date.Subtract(quantity);
Assert.IsNull(result);
}

[TestMethod]
public void Operator_Addition_NullDate_ReturnsNull()
{
CqlDate? date = null;
var quantity = new CqlQuantity(1, "day");
var result = date + quantity;
Assert.IsNull(result);
}

[TestMethod]
public void Operator_Subtraction_NullDate_ReturnsNull()
{
CqlDate? date = null;
var quantity = new CqlQuantity(1, "day");
var result = date - quantity;
Assert.IsNull(result);
}
}
Loading