Skip to content

Fix disabled date calculator unit tests - #2332

Closed
Ronit Sabhaya (Ronitsabhaya75) wants to merge 6 commits into
microsoft:mainfrom
Ronitsabhaya75:main
Closed

Fix disabled date calculator unit tests#2332
Ronit Sabhaya (Ronitsabhaya75) wants to merge 6 commits into
microsoft:mainfrom
Ronitsabhaya75:main

Conversation

@Ronitsabhaya75

Copy link
Copy Markdown

Fix TestDateDiff, TestAddOob, TestAddition, and TestSubtraction unit tests in DateCalculatorUnitTests.cpp by updating API calls to match current interfaces and adding proper verification steps. These tests were previously disabled with TODO comments referencing MSFT 10331900.

@Ronitsabhaya75

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@tian-lt

Copy link
Copy Markdown
Contributor

Hi hanzhang54, do you know what MSFT 10331900 is? Could you help verify if our pipelines can pass once those test code is enabled? Thanks.

@Ronitsabhaya75

Copy link
Copy Markdown
Author

Tian L. (@tian-lt) Can you please review this and suggest any changes

@Kve-sudo

Kve-sudo commented Jul 4, 2025

Copy link
Copy Markdown

@

@tian-lt

Copy link
Copy Markdown
Contributor

Ronit Sabhaya (@Ronitsabhaya75) There seems to be some build errors about the changes in this PR. Could you please take a look?

##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): Error C2660: 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference': function does not take 4 arguments
4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): error C2660: 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference': function does not take 4 arguments [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj]
(compiling source file '/DateCalculatorUnitTests.cpp')
D:\a_work\1\s\src\CalcViewModel\Common\DateCalculator.h(55,39):
see declaration of 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference'
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50):
while trying to match the argument list '(Windows::Foundation::DateTime, Windows::Foundation::DateTime, CalculatorApp::ViewModel::Common::DateCalculation::DateUnit, CalculatorApp::ViewModel::Common::DateCalculation::DateDifference *)'

##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): Error C2440: 'initializing': cannot convert from 'Platform::IBoxCalculatorApp::ViewModel::Common::DateCalculation::DateDifference ^' to 'bool'
4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): error C2440: 'initializing': cannot convert from 'Platform::IBoxCalculatorApp::ViewModel::Common::DateCalculation::DateDifference ^' to 'bool' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj]
(compiling source file '/DateCalculatorUnitTests.cpp')
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30):
No user-defined-conversion operator available, or
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30):
There is no context in which this conversion is possible

##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): Error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime'
4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj]
(compiling source file '/DateCalculatorUnitTests.cpp')
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,73):
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\a_work\1\s\src\CalculatorUnitTests\DateUtils.h(28,27):
see declaration of 'DateCalculationUnitTests::DateUtils::DateTimeToSystemTime'
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52):
while trying to match the argument list '(Platform::IBoxWindows::Foundation::DateTime)'

##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): Error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime'
4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj]
(compiling source file '/DateCalculatorUnitTests.cpp')
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,73):
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\a_work\1\s\src\CalculatorUnitTests\DateUtils.h(28,27):
see declaration of 'DateCalculationUnitTests::DateUtils::DateTimeToSystemTime'
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52):
while trying to match the argument list '(Platform::IBoxWindows::Foundation::DateTime)'

@Ronitsabhaya75

Copy link
Copy Markdown
Author

Ronit Sabhaya (@Ronitsabhaya75) There seems to be some build errors about the changes in this PR. Could you please take a look?

##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): Error C2660: 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference': function does not take 4 arguments
4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): error C2660: 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference': function does not take 4 arguments [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj]
(compiling source file '/DateCalculatorUnitTests.cpp')
D:\a_work\1\s\src\CalcViewModel\Common\DateCalculator.h(55,39):
see declaration of 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference'
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50):
while trying to match the argument list '(Windows::Foundation::DateTime, Windows::Foundation::DateTime, CalculatorApp::ViewModel::Common::DateCalculation::DateUnit, CalculatorApp::ViewModel::Common::DateCalculation::DateDifference *)'
##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): Error C2440: 'initializing': cannot convert from 'Platform::IBoxCalculatorApp::ViewModel::Common::DateCalculation::DateDifference ^' to 'bool'
4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): error C2440: 'initializing': cannot convert from 'Platform::IBoxCalculatorApp::ViewModel::Common::DateCalculation::DateDifference ^' to 'bool' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj]
(compiling source file '/DateCalculatorUnitTests.cpp')
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30):
No user-defined-conversion operator available, or
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30):
There is no context in which this conversion is possible
##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): Error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime'
4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj]
(compiling source file '/DateCalculatorUnitTests.cpp')
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,73):
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\a_work\1\s\src\CalculatorUnitTests\DateUtils.h(28,27):
see declaration of 'DateCalculationUnitTests::DateUtils::DateTimeToSystemTime'
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52):
while trying to match the argument list '(Platform::IBoxWindows::Foundation::DateTime)'
##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): Error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime'
4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj]
(compiling source file '/DateCalculatorUnitTests.cpp')
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,73):
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\a_work\1\s\src\CalculatorUnitTests\DateUtils.h(28,27):
see declaration of 'DateCalculationUnitTests::DateUtils::DateTimeToSystemTime'
D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52):
while trying to match the argument list '(Platform::IBoxWindows::Foundation::DateTime)'

yes I can have look

@tian-lt

Copy link
Copy Markdown
Contributor

And, something might be wrong about the checks for this PR. please allow me to close and reopen this PR so that we can trigger the GitHub Action for the PR. Thanks.

@Ronitsabhaya75

Copy link
Copy Markdown
Author

Tian L. (@tian-lt) can you please review this changes. sorry for pushing this late i was actually busy with my intern program.

@tian-lt

Copy link
Copy Markdown
Contributor

Ronit Sabhaya (@Ronitsabhaya75) thank you for pushing a fix.
Looks like we have a run time failure in UT for now. Could you help take a look?

Failed TestDateDiff [< 1 ms]
Error Message:
Assert failed

@Ronitsabhaya75

Copy link
Copy Markdown
Author

Ronit Sabhaya (@Ronitsabhaya75) thank you for pushing a fix. Looks like we have a run time failure in UT for now. Could you help take a look?

Failed TestDateDiff [< 1 ms]
Error Message:
Assert failed

let me see that and fix it

@Ronitsabhaya75

Copy link
Copy Markdown
Author

Tian L. (@tian-lt) i think this should fix now can you run it through all tests

@Ronitsabhaya75

Copy link
Copy Markdown
Author

Tian L. (@tian-lt) is it possible to run the test and see if this is failing or not.

@tian-lt

Copy link
Copy Markdown
Contributor

Tian L. (@tian-lt) is it possible to run the test and see if this is failing or not.

sure. I’ve triggered a run for it. BTW, the Unit tests are able to run on your local machine. It will give you more information about the test failure.

@Ronitsabhaya75

Copy link
Copy Markdown
Author

Tian L. (@tian-lt) is it possible to run the test and see if this is failing or not.

sure. I’ve triggered a run for it. BTW, the Unit tests are able to run on your local machine. It will give you more information about the test failure.

I tested them they were working correctly i honestly dont know why is this causing issue here

@Ronitsabhaya75

Copy link
Copy Markdown
Author

Tian L. (@tian-lt) can you give me access to trigger those test manually for this pr for checking

@Ronitsabhaya75 Ronit Sabhaya (Ronitsabhaya75) closed this by deleting the head repository Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants