xref: /third_party/ninja/src/status_test.cc (revision 695b41ee)
1// Copyright 2011 Google Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "status.h"
16
17#include "test.h"
18
19TEST(StatusTest, StatusFormatElapsed) {
20  BuildConfig config;
21  StatusPrinter status(config);
22
23  status.BuildStarted();
24  // Before any task is done, the elapsed time must be zero.
25  EXPECT_EQ("[%/e0.000]", status.FormatProgressStatus("[%%/e%e]", 0));
26  // Before any task is done, the elapsed time must be zero.
27  EXPECT_EQ("[%/e00:00]", status.FormatProgressStatus("[%%/e%w]", 0));
28}
29
30TEST(StatusTest, StatusFormatReplacePlaceholder) {
31  BuildConfig config;
32  StatusPrinter status(config);
33
34  EXPECT_EQ("[%/s0/t0/r0/u0/f0]",
35            status.FormatProgressStatus("[%%/s%s/t%t/r%r/u%u/f%f]", 0));
36}
37