diff --git a/test/date_test/op_div_day_day.fail.cpp b/test/date_test/op_div_day_day.fail.cpp new file mode 100644 index 0000000..77cbef2 --- /dev/null +++ b/test/date_test/op_div_day_day.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// day / day not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = 14_d/14_d; +} diff --git a/test/date_test/op_div_int_month.fail.cpp b/test/date_test/op_div_int_month.fail.cpp new file mode 100644 index 0000000..8c8a6e8 --- /dev/null +++ b/test/date_test/op_div_int_month.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// int / month not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = 8/aug; +} diff --git a/test/date_test/op_div_int_year.fail.cpp b/test/date_test/op_div_int_year.fail.cpp new file mode 100644 index 0000000..507c2be --- /dev/null +++ b/test/date_test/op_div_int_year.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// int / year not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = 8/2015_y; +} diff --git a/test/date_test/op_div_last_last.fail.cpp b/test/date_test/op_div_last_last.fail.cpp new file mode 100644 index 0000000..345b4d6 --- /dev/null +++ b/test/date_test/op_div_last_last.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// last / last not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = last/last; +} diff --git a/test/date_test/op_div_month_day.pass.cpp b/test/date_test/op_div_month_day.pass.cpp new file mode 100644 index 0000000..55f0ce2 --- /dev/null +++ b/test/date_test/op_div_month_day.pass.cpp @@ -0,0 +1,41 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr month_day operator/(const month& m, const day& d) noexcept; +// constexpr month_day operator/(const month& m, int d) noexcept; +// constexpr month_day operator/(int m, const day& d) noexcept; +// constexpr month_day operator/(const day& d, const month& m) noexcept; +// constexpr month_day operator/(const day& d, int m) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert( aug/14_d == month_day{month{8}, day{14}}, ""); + static_assert( aug/14 == month_day{month{8}, day{14}}, ""); + static_assert( 8/14_d == month_day{month{8}, day{14}}, ""); + static_assert(14_d/aug == month_day{month{8}, day{14}}, ""); + static_assert(14_d/8 == month_day{month{8}, day{14}}, ""); +} diff --git a/test/date_test/op_div_month_day_last.pass.cpp b/test/date_test/op_div_month_day_last.pass.cpp new file mode 100644 index 0000000..37a8f4d --- /dev/null +++ b/test/date_test/op_div_month_day_last.pass.cpp @@ -0,0 +1,39 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr month_day_last operator/(const month& m, last_spec) noexcept; +// constexpr month_day_last operator/(int m, last_spec) noexcept; +// constexpr month_day_last operator/(last_spec, const month& m) noexcept; +// constexpr month_day_last operator/(last_spec, int m) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert( aug/last == month_day_last{month{8}}, ""); + static_assert( 8/last == month_day_last{month{8}}, ""); + static_assert(last/aug == month_day_last{month{8}}, ""); + static_assert(last/8 == month_day_last{month{8}}, ""); +} diff --git a/test/date_test/op_div_month_day_month_day.fail.cpp b/test/date_test/op_div_month_day_month_day.fail.cpp new file mode 100644 index 0000000..ce087b3 --- /dev/null +++ b/test/date_test/op_div_month_day_month_day.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// month_day / month_day not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = (aug/14_d)/(aug/14_d); +} diff --git a/test/date_test/op_div_month_month.fail.cpp b/test/date_test/op_div_month_month.fail.cpp new file mode 100644 index 0000000..db6ebe0 --- /dev/null +++ b/test/date_test/op_div_month_month.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// month / month not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = aug/aug; +} diff --git a/test/date_test/op_div_month_weekday.pass.cpp b/test/date_test/op_div_month_weekday.pass.cpp new file mode 100644 index 0000000..99e1f74 --- /dev/null +++ b/test/date_test/op_div_month_weekday.pass.cpp @@ -0,0 +1,39 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr month_weekday operator/(const month& m, const weekday_indexed& wdi) noexcept; +// constexpr month_weekday operator/(int m, const weekday_indexed& wdi) noexcept; +// constexpr month_weekday operator/(const weekday_indexed& wdi, const month& m) noexcept; +// constexpr month_weekday operator/(const weekday_indexed& wdi, int m) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert( aug/fri[2] == month_weekday{month{8}, weekday_indexed{weekday{5}, 2}}, ""); + static_assert( 8/fri[2] == month_weekday{month{8}, weekday_indexed{weekday{5}, 2}}, ""); + static_assert(fri[2]/aug == month_weekday{month{8}, weekday_indexed{weekday{5}, 2}}, ""); + static_assert(fri[2]/8 == month_weekday{month{8}, weekday_indexed{weekday{5}, 2}}, ""); +} diff --git a/test/date_test/op_div_month_weekday_last.pass.cpp b/test/date_test/op_div_month_weekday_last.pass.cpp new file mode 100644 index 0000000..ace85e0 --- /dev/null +++ b/test/date_test/op_div_month_weekday_last.pass.cpp @@ -0,0 +1,39 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr month_weekday_last operator/(const month& m, const weekday_last& wdl) noexcept; +// constexpr month_weekday_last operator/(int m, const weekday_last& wdl) noexcept; +// constexpr month_weekday_last operator/(const weekday_last& wdl, const month& m) noexcept; +// constexpr month_weekday_last operator/(const weekday_last& wdl, int m) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert( aug/fri[last] == month_weekday_last{month{8}, weekday_last{weekday{5}}}, ""); + static_assert( 8/fri[last] == month_weekday_last{month{8}, weekday_last{weekday{5}}}, ""); + static_assert(fri[last]/aug == month_weekday_last{month{8}, weekday_last{weekday{5}}}, ""); + static_assert(fri[last]/8 == month_weekday_last{month{8}, weekday_last{weekday{5}}}, ""); +} diff --git a/test/date_test/op_div_month_year.fail.cpp b/test/date_test/op_div_month_year.fail.cpp new file mode 100644 index 0000000..4cadfde --- /dev/null +++ b/test/date_test/op_div_month_year.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// month / year not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = aug/2015_y; +} diff --git a/test/date_test/op_div_weekday_indexed_weekday_indexed.fail.cpp b/test/date_test/op_div_weekday_indexed_weekday_indexed.fail.cpp new file mode 100644 index 0000000..ab969ee --- /dev/null +++ b/test/date_test/op_div_weekday_indexed_weekday_indexed.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// weekday_indexed / weekday_indexed not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = fri[2]/fri[2]; +} diff --git a/test/date_test/op_div_weekday_last_weekday_last.fail.cpp b/test/date_test/op_div_weekday_last_weekday_last.fail.cpp new file mode 100644 index 0000000..fa8ff7a --- /dev/null +++ b/test/date_test/op_div_weekday_last_weekday_last.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// weekday_last / weekday_last not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = fri[last]/fri[last]; +} diff --git a/test/date_test/op_div_year_month.pass.cpp b/test/date_test/op_div_year_month.pass.cpp new file mode 100644 index 0000000..0639aaf --- /dev/null +++ b/test/date_test/op_div_year_month.pass.cpp @@ -0,0 +1,35 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr year_month operator/(const year& y, const month& m) noexcept; +// constexpr year_month operator/(const year& y, int m) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert(2015_y/aug == year_month{year{2015}, aug}, ""); + static_assert(2015_y/8 == year_month{year{2015}, aug}, ""); +} diff --git a/test/date_test/op_div_year_month_day.pass.cpp b/test/date_test/op_div_year_month_day.pass.cpp new file mode 100644 index 0000000..b415312 --- /dev/null +++ b/test/date_test/op_div_year_month_day.pass.cpp @@ -0,0 +1,43 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr year_month_day operator/(const year_month& ym, const day& d) noexcept; +// constexpr year_month_day operator/(const year_month& ym, int d) noexcept; +// constexpr year_month_day operator/(const year& y, const month_day& md) noexcept; +// constexpr year_month_day operator/(int y, const month_day& md) noexcept; +// constexpr year_month_day operator/(const month_day& md, const year& y) noexcept; +// constexpr year_month_day operator/(const month_day& md, int y) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert( 2015_y/aug/14_d == year_month_day{year{2015}, month{8}, day{14}}, ""); + static_assert( 2015_y/aug/14 == year_month_day{year{2015}, month{8}, day{14}}, ""); + static_assert( 2015_y/(aug/14_d) == year_month_day{year{2015}, month{8}, day{14}}, ""); + static_assert( 2015/(aug/14_d) == year_month_day{year{2015}, month{8}, day{14}}, ""); + static_assert(aug/14_d/2015_y == year_month_day{year{2015}, month{8}, day{14}}, ""); + static_assert(aug/14_d/2015 == year_month_day{year{2015}, month{8}, day{14}}, ""); +} diff --git a/test/date_test/op_div_year_month_day_last.pass.cpp b/test/date_test/op_div_year_month_day_last.pass.cpp new file mode 100644 index 0000000..20c3e55 --- /dev/null +++ b/test/date_test/op_div_year_month_day_last.pass.cpp @@ -0,0 +1,41 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr year_month_day_last operator/(const year_month& ym, last_spec) noexcept; +// constexpr year_month_day_last operator/(const year& y, const month_day_last& mdl) noexcept; +// constexpr year_month_day_last operator/(int y, const month_day_last& mdl) noexcept; +// constexpr year_month_day_last operator/(const month_day_last& mdl, const year& y) noexcept; +// constexpr year_month_day_last operator/(const month_day_last& mdl, int y) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert(2015_y/aug/last == year_month_day_last{year{2015}, month_day_last{month{8}}}, ""); + static_assert( 2015_y/(aug/last) == year_month_day_last{year{2015}, month_day_last{month{8}}}, ""); + static_assert( 2015/(aug/last) == year_month_day_last{year{2015}, month_day_last{month{8}}}, ""); + static_assert( aug/last/2015_y == year_month_day_last{year{2015}, month_day_last{month{8}}}, ""); + static_assert( aug/last/2015 == year_month_day_last{year{2015}, month_day_last{month{8}}}, ""); +} diff --git a/test/date_test/op_div_year_month_weekday.pass.cpp b/test/date_test/op_div_year_month_weekday.pass.cpp new file mode 100644 index 0000000..9e437b3 --- /dev/null +++ b/test/date_test/op_div_year_month_weekday.pass.cpp @@ -0,0 +1,41 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr year_month_weekday operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; +// constexpr year_month_weekday operator/(const year& y, const month_weekday& mwd) noexcept; +// constexpr year_month_weekday operator/(int y, const month_weekday& mwd) noexcept; +// constexpr year_month_weekday operator/(const month_weekday& mwd, const year& y) noexcept; +// constexpr year_month_weekday operator/(const month_weekday& mwd, int y) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert(2015_y/aug/fri[2] == year_month_weekday{year{2015}, month{8}, weekday_indexed{weekday{5}, 2}}, ""); + static_assert( 2015_y/(aug/fri[2]) == year_month_weekday{year{2015}, month{8}, weekday_indexed{weekday{5}, 2}}, ""); + static_assert( 2015/(aug/fri[2]) == year_month_weekday{year{2015}, month{8}, weekday_indexed{weekday{5}, 2}}, ""); + static_assert(aug/fri[2]/2015_y == year_month_weekday{year{2015}, month{8}, weekday_indexed{weekday{5}, 2}}, ""); + static_assert(aug/fri[2]/2015 == year_month_weekday{year{2015}, month{8}, weekday_indexed{weekday{5}, 2}}, ""); +} diff --git a/test/date_test/op_div_year_month_weekday_last.pass.cpp b/test/date_test/op_div_year_month_weekday_last.pass.cpp new file mode 100644 index 0000000..d75710a --- /dev/null +++ b/test/date_test/op_div_year_month_weekday_last.pass.cpp @@ -0,0 +1,41 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// constexpr year_month_weekday_last operator/(const year_month& ym, const weekday_last& wdl) noexcept; +// constexpr year_month_weekday_last operator/(const year& y, const month_weekday_last& mwdl) noexcept; +// constexpr year_month_weekday_last operator/(int y, const month_weekday_last& mwdl) noexcept; +// constexpr year_month_weekday_last operator/(const month_weekday_last& mwdl, const year& y) noexcept; +// constexpr year_month_weekday_last operator/(const month_weekday_last& mwdl, int y) noexcept; + +#include "date.h" + +int +main() +{ + using namespace date; + + static_assert( 2015_y/aug/fri[last] == year_month_weekday_last{year{2015}, month{8}, weekday_last{weekday{5}}}, ""); + static_assert( 2015_y/(aug/fri[last]) == year_month_weekday_last{year{2015}, month{8}, weekday_last{weekday{5}}}, ""); + static_assert( 2015/(aug/fri[last]) == year_month_weekday_last{year{2015}, month{8}, weekday_last{weekday{5}}}, ""); + static_assert(aug/fri[last]/2015_y == year_month_weekday_last{year{2015}, month{8}, weekday_last{weekday{5}}}, ""); + static_assert(aug/fri[last]/2015 == year_month_weekday_last{year{2015}, month{8}, weekday_last{weekday{5}}}, ""); +} diff --git a/test/date_test/op_div_year_month_year_month.fail.cpp b/test/date_test/op_div_year_month_year_month.fail.cpp new file mode 100644 index 0000000..8201d73 --- /dev/null +++ b/test/date_test/op_div_year_month_year_month.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// year_month / year_month not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = (2015_y/aug)/(2015_y/aug); +} diff --git a/test/date_test/op_div_year_year.fail.cpp b/test/date_test/op_div_year_year.fail.cpp new file mode 100644 index 0000000..4ba0902 --- /dev/null +++ b/test/date_test/op_div_year_year.fail.cpp @@ -0,0 +1,33 @@ +// The MIT License (MIT) +// +// Copyright (c) 2015 Howard Hinnant +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// year / year not allowed + +#include "date.h" + +int +main() +{ + using namespace date; + + auto x = 2015_y/2015_y; +} diff --git a/test/date_test/year_month_day_last.pass.cpp b/test/date_test/year_month_day_last.pass.cpp index 8f789d3..fdd1df0 100644 --- a/test/date_test/year_month_day_last.pass.cpp +++ b/test/date_test/year_month_day_last.pass.cpp @@ -152,10 +152,12 @@ main() static_assert(ymdl1.year() == 2015_y, ""); static_assert(ymdl1.month() == aug, ""); static_assert(ymdl1.month_day_last() == month_day_last{aug}, ""); +#if __cplusplus >= 201402 static_assert(ymdl1.day() == 31_d, ""); constexpr day_point dp = ymdl1; constexpr year_month_day ymd = dp; static_assert(ymd == 2015_y/aug/31, ""); +#endif constexpr year_month_day_last ymdl2 = {2015_y, month_day_last{sep}}; diff --git a/test/date_test/year_month_weekday.pass.cpp b/test/date_test/year_month_weekday.pass.cpp index 86bebf0..1986de1 100644 --- a/test/date_test/year_month_weekday.pass.cpp +++ b/test/date_test/year_month_weekday.pass.cpp @@ -147,13 +147,17 @@ main() using namespace date; constexpr year_month_weekday ymdl1 = {2015_y, aug, weekday_indexed{fri, 2}}; +#if __cplusplus >= 201402 static_assert(ymdl1.ok(), ""); +#endif static_assert(ymdl1.year() == 2015_y, ""); static_assert(ymdl1.month() == aug, ""); static_assert(ymdl1.weekday_indexed() == fri[2], ""); +#if __cplusplus >= 201402 constexpr day_point dp = ymdl1; constexpr year_month_day ymd = dp; static_assert(ymd == 2015_y/aug/14, ""); +#endif constexpr year_month_weekday ymdl2 = sat[1]/aug/2015; diff --git a/test/date_test/year_month_weekday_last.pass.cpp b/test/date_test/year_month_weekday_last.pass.cpp index 8f6abeb..2dead76 100644 --- a/test/date_test/year_month_weekday_last.pass.cpp +++ b/test/date_test/year_month_weekday_last.pass.cpp @@ -147,9 +147,11 @@ main() static_assert(ymdl1.year() == 2015_y, ""); static_assert(ymdl1.month() == aug, ""); static_assert(ymdl1.weekday_last() == fri[last], ""); +#if __cplusplus >= 201402 constexpr day_point dp = ymdl1; constexpr year_month_day ymd = dp; static_assert(ymd == 2015_y/aug/28, ""); +#endif constexpr year_month_weekday_last ymdl2 = sat[last]/aug/2015;