Skip to content

Commit

Permalink
Adding a combined version define in MaterialX C++
Browse files Browse the repository at this point in the history
Signed-off-by: Rui Yang <[email protected]>
  • Loading branch information
ruiyang2021 committed Sep 27, 2024
1 parent 80e1b56 commit 3dd8145
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/MaterialXCore/Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#ifndef MATERIALX_LIBRARY_H
#define MATERIALX_LIBRARY_H

#define MATERIALX_GENERATE_INDEX(major, minor, build) \
((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(build)))
#define MATERIALX_VERSION_INDEX \
MATERIALX_GENERATE_INDEX(MATERIALX_MAJOR_VERSION, MATERIALX_MINOR_VERSION, MATERIALX_BUILD_VERSION)

/// @file
/// Library-wide includes and types. This file should be the first include for
/// any public header in the MaterialX library.
Expand Down
16 changes: 16 additions & 0 deletions source/MaterialXTest/MaterialXCore/Library.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright Contributors to the MaterialX Project
// SPDX-License-Identifier: Apache-2.0
//

#include <MaterialXTest/External/Catch/catch.hpp>

#include <MaterialXCore/Library.h>

namespace mx = MaterialX;

TEST_CASE("Version comparison", "[library]")
{
// Test for version comparison
REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8));
}

0 comments on commit 3dd8145

Please sign in to comment.