Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/49#discussion_r69986183
  
    --- Diff: storage/tests/WindowAggregationOperationState_unittest.cpp ---
    @@ -0,0 +1,91 @@
    +/**
    + *   Copyright 2011-2015 Quickstep Technologies LLC.
    + *   Copyright 2015-2016 Pivotal Software, Inc.
    + *   Copyright 2016, Quickstep Research Group, Computer Sciences 
Department,
    + *     University of Wisconsin—Madison.
    + *
    + *   Licensed under the Apache License, Version 2.0 (the "License");
    + *   you may not use this file except in compliance with the License.
    + *   You may obtain a copy of the License at
    + *
    + *       http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *   Unless required by applicable law or agreed to in writing, software
    + *   distributed under the License is distributed on an "AS IS" BASIS,
    + *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
    + *   See the License for the specific language governing permissions and
    + *   limitations under the License.
    + **/
    +
    +#include <cstddef>
    +#include <memory>
    +
    +#include "catalog/CatalogDatabase.hpp"
    +#include "catalog/CatalogRelation.hpp"
    +#include "catalog/CatalogTypedefs.hpp"
    +#include "expressions/aggregation/AggregateFunction.pb.h"
    +#include "storage/WindowAggregationOperationState.hpp"
    +#include "storage/WindowAggregationOperationState.pb.h"
    +
    +#include "gtest/gtest.h"
    +
    +using std::unique_ptr;
    +
    +namespace quickstep {
    +
    +class WindowAggregationOperationStateProtoTest : public ::testing::Test {
    + protected:
    +  static const relation_id kInvalidTableId = 100;
    +  static const std::int64_t kInvalidNum = -10;
    +  static const std::int64_t kValidNum = 10;
    +
    +  virtual void SetUp() {
    +    database_.reset(new CatalogDatabase(nullptr, "db"));
    +    rel_id_ = database_->addRelation(new CatalogRelation(nullptr, "rel"));
    +  }
    +
    +  unique_ptr<CatalogDatabase> database_;
    +  relation_id rel_id_;
    +};
    +
    +TEST_F(WindowAggregationOperationStateProtoTest, UninitializationTest) {
    +  serialization::WindowAggregationOperationState proto;
    +  EXPECT_FALSE(WindowAggregationOperationState::ProtoIsValid(proto, 
*database_.get()));
    +}
    +
    +TEST_F(WindowAggregationOperationStateProtoTest, InvalidRelationIdTest) {
    +  serialization::WindowAggregationOperationState proto;
    +  proto.set_relation_id(kInvalidTableId);
    +  
proto.mutable_function()->set_aggregation_id(serialization::AggregateFunction::AVG);
    +  proto.set_is_row(true);
    +  proto.set_num_preceding(kValidNum);
    +  proto.set_num_following(kValidNum);
    +  EXPECT_FALSE(WindowAggregationOperationState::ProtoIsValid(proto, 
*database_.get()));
    +}
    +
    +TEST_F(WindowAggregationOperationStateProtoTest, InvalidNumTest) {
    +  serialization::WindowAggregationOperationState proto;
    +  proto.set_relation_id(rel_id_);
    +  
proto.mutable_function()->set_aggregation_id(serialization::AggregateFunction::AVG);
    +  proto.set_is_row(true);
    +  proto.set_num_preceding(kInvalidNum);
    +  proto.set_num_following(kValidNum);
    +  EXPECT_FALSE(WindowAggregationOperationState::ProtoIsValid(proto, 
*database_.get()));
    +
    +  proto.set_num_preceding(kValidNum);
    +  proto.set_num_following(kInvalidNum);
    +  EXPECT_FALSE(WindowAggregationOperationState::ProtoIsValid(proto, 
*database_.get()));
    +}
    +
    +TEST_F(WindowAggregationOperationStateProtoTest, ValidTest) {
    +  serialization::WindowAggregationOperationState proto;
    +  proto.set_relation_id(rel_id_);
    +  
proto.mutable_function()->set_aggregation_id(serialization::AggregateFunction::AVG);
    +  proto.set_is_row(true);
    +  proto.set_num_preceding(kValidNum);
    +  proto.set_num_following(kValidNum);
    +  EXPECT_TRUE(WindowAggregationOperationState::ProtoIsValid(proto, 
*database_.get()));
    +}
    +
    +}  // namespace quickstep
    +
    --- End diff --
    
    Please remove this empty line.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to