Summary: @public Adds tests for `YGFloatOptional`, to ease refactorings. Reviewed By: SidharthGuglani Differential Revision: D13439610 fbshipit-source-id: e29da7f85ccedc46520b59f6c893bad521d35417
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
* file in the root directory of this source tree.
|
|
*/
|
|
#pragma once
|
|
|
|
struct YGFloatOptional {
|
|
private:
|
|
float value_ = 0;
|
|
bool isUndefined_ = true;
|
|
|
|
public:
|
|
explicit YGFloatOptional(float value);
|
|
YGFloatOptional() = default;
|
|
|
|
// Program will terminate if the value of an undefined is accessed. Please
|
|
// make sure to check if the optional is defined before calling this function.
|
|
// To check if float optional is defined, use `isUndefined()`.
|
|
float getValue() const;
|
|
|
|
// Sets the value of float optional, and thus isUndefined is assigned false.
|
|
void setValue(float val) {
|
|
value_ = val;
|
|
isUndefined_ = false;
|
|
}
|
|
|
|
bool isUndefined() const {
|
|
return isUndefined_;
|
|
}
|
|
|
|
YGFloatOptional operator+(const YGFloatOptional& op) const;
|
|
bool operator>(const YGFloatOptional& op) const;
|
|
bool operator<(const YGFloatOptional& op) const;
|
|
bool operator>=(const YGFloatOptional& op) const;
|
|
bool operator<=(const YGFloatOptional& op) const;
|
|
bool operator==(const YGFloatOptional& op) const;
|
|
bool operator!=(const YGFloatOptional& op) const;
|
|
|
|
bool operator==(float val) const;
|
|
bool operator!=(float val) const;
|
|
};
|